Enable_Disable Control Panel and Settings using AutoHotkey
I'm Trying to create HotKeys that would Enable and Disable the Windows Control Panel and Settings.
I currently have the following:
!f2:: ; This will Disable the Windows Control Panel and Settings.
Run "C:\Enable_Disable Control Panel and Settings\Disable Control Panel and Settings.reg"
Return
!f1:: ; This will Enable the Windows Control Panel and Settings.
Run "C:\Enable_Disable Control Panel and Settings\Enable Control Panel and Settings (default).reg"
Return
which is working fine since it runs the registry files which write to the Registry the keys as shown below respectively.
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoControlPanel"=dword:00000000
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoControlPanel"=dword:00000001
But I would like to have a script that will automatically write to the registry without using the Run command.
I tried the following:
!f4:: ; This will Disable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 1
Return
!f3:: ; This will Enable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 0
Return
But it didn't work. I'm not sure what I'm doing wrong. Is it permissions, or something else?
Enable_Disable Control Panel and Settings using AutoHotkey
Re: Enable_Disable Control Panel and Settings using AutoHotkey
Run your script as admin, this works for me
Re: Enable_Disable Control Panel and Settings using AutoHotkey
I run the script at startup. Since I place it in the common startup folder.
Is there a way to set it to be as administrator, or to script proper permissions?
Is there a way to set it to be as administrator, or to script proper permissions?
Re: Enable_Disable Control Panel and Settings using AutoHotkey
I've been reading and trying to understand the different commands, but I'm not very versed.
I would like the script to gain administrative permissions and be able to write to registry regardless of the user.
I would like the script to gain administrative permissions and be able to write to registry regardless of the user.
Re: Enable_Disable Control Panel and Settings using AutoHotkey
I wanted to mention that I figured it out.
The script is fine the way it is.
And to skip all the UAC prompts, and to be able to run at startup, you simply need to set up a task in the Task Scheduler to run on user logon and to run with highest privileges.
Also I compiled the script into an EXE and selected it as the program to be ran at logon.
That's it.
Raudel
The script is fine the way it is.
And to skip all the UAC prompts, and to be able to run at startup, you simply need to set up a task in the Task Scheduler to run on user logon and to run with highest privileges.
Also I compiled the script into an EXE and selected it as the program to be ran at logon.
That's it.
Raudel
Re: Enable_Disable Control Panel and Settings using AutoHotkey
I don't feel like swapping users and actually testing this, but I know it used to work ... could be a starting point for you to test :
Code: Select all
RunAsAdmin()
{
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
}
}
Re: Enable_Disable Control Panel and Settings using AutoHotkey
Tried the following, It didn't work to run my script as Administrator. I'm a real newby. Sorry. I must really be doing something wrong.
RunAsAdmin()
{
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
}
}
!f2:: ; This will Disable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 1
Return
!f1:: ; This will Enable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 0
Return
#NoTrayIcon
#SingleInstance force
I also tried
RunAsAdmin() {
Loop, %0% ; For each parameter:
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
params .= A_Space . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
ExitApp
}
}
!f2:: ; This will Disable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 1
Return
!f1:: ; This will Enable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 0
Return
#NoTrayIcon
#SingleInstance force
RunAsAdmin()
{
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """", str, A_WorkingDir, int, 1)
}
}
!f2:: ; This will Disable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 1
Return
!f1:: ; This will Enable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 0
Return
#NoTrayIcon
#SingleInstance force
I also tried
RunAsAdmin() {
Loop, %0% ; For each parameter:
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
params .= A_Space . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
ExitApp
}
}
!f2:: ; This will Disable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 1
Return
!f1:: ; This will Enable the Windows Control Panel and Settings.
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer, NoControlPanel, 0
Return
#NoTrayIcon
#SingleInstance force
Who is online
Users browsing this forum: Google [Bot], jameswrightesq and 416 guests