Windows – Disable UAC from cmd (scriptable)

batfile

win7uac

When this needed:

A few years ago I built an automatic installer packages with “WPI” – Windows Post Install. When Vista arrived, Microsoft built User Account Control in further windows as a security component. This mechanism is an entry-level defense. Not to smart & not to effective, but in a lot of cases prevent windows’s internal files from damage.

But UAC also block automatic scripts / batch files. This is the reason, why I must to need use this windows command before I start to install applications to a freshly installed Windows vista / 7 / 8 / 8.1 / 10.

How can you use it:

This command must to be run as administrator. When windows script was finished, it will restart the computer to activate “disable UAC” as it needed. You will have 60sec to save your sessions (opened word / excel doc; txt;…)

Batch script:

To disable it:

title CH-E-MISTRY

cd /d %~dp0

rem with "/c" option it will be quit, with "/k" it will return

%windir%\System32\cmd.exe /c %windir%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
%windir%\System32\cmd.exe /c %windir%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f

shutdown -r -t 60 -c "Windows will be restart after 60sec. To interrupt it (in cmd-prompt): shutdown minus a"
  • To interrupt reboot –> open a command-prompt –> shutdown -a
  • The name of batch is not important but the extension must be: “xxxxxx.cmd

To enable it:

title CH-E-MISTRY

cd /d %~dp0

%windir%\System32\cmd.exe /c %windir%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f
%windir%\System32\cmd.exe /c %windir%\System32\reg.exe ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 2 /f

EXIT
  • The name of batch is not important but the extension must be: “xxxxxx.cmd

Leave a Reply