I have a strange problem here. I am trying to disable UAC via the command line (batch file) and by using REG.EXE (as it doesn't ask for UAC access itself). I have been able to create a shortcut (.lnk) with the target:

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f

If I run that as an administrator - there is no problem at all, it changes the registry. If I try to run that command via the command line itself (run as the exact same administrator), I get access denied.

Eventually, I want to move it to a batch script, but that should be no problem once I am able to run it on the command line. Any ideas? Thank you.

2 Answers 2


Just because it doesn't prompt for UAC escalation, doesn't mean it doesn't need it.

It needs it.

You'll need to run it from an escalated context - an escalated command prompt, a scheduled task with "run as highest privilege" checked, something. The registry simply cannot be modified without some form of privilege escalation.

  • I understand that, but I am running the .lnk as an admin (right click) and it works (even opens a command prompt itself stating success), but when I run it from an admin command prompt, I get access denied.
    – naspinski
    Jul 19, 2011 at 21:58
  • 1
    Are you right-clicking cmd.exe and running as admin, and does it say Administrator: Command Prompt at the top of the window? Saying "run as the exact same administrator" isn't the same as running with UAC escalation privileges - it's completely separate from the privileges of your user. It works just as expected for me: i.stack.imgur.com/erKIY.jpg Jul 19, 2011 at 22:16
  • When I am running in the command prompy, it is not 'Administrator: Command Prompt' - I just do a runas cmd. I may see the problem now. Can I get the 'run as administrator' with the .lnk behavior with the command prompt in any way? A runas does not seem to work...
    – naspinski
    Jul 20, 2011 at 18:25
  • A command prompt session can be escalated by right-clicking cmd.exe and running as admin. Jul 20, 2011 at 18:33
  • is there any way to get that behavior via command line? Without right-clicking?
    – naspinski
    Jul 20, 2011 at 18:55

You need an elevated context to do it. I searched too much for a task that I needed, and couldn't find a way to request an elevation from the prompt in a batch file.

However, contrary to what Shane Madden has mentioned in the comments of the previous answer, I've been using Prio from prnwatch.com since time immemorial to do automatic silent elevation of certain processes. Naturally, you cannot count on this if you will be distributing your batch file to run on other computers....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .