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.

link|improve this question

60% accept rate
feedback

1 Answer

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.

link|improve this answer
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 '11 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 – Shane Madden Jul 19 '11 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 '11 at 18:25
A command prompt session can be escalated by right-clicking cmd.exe and running as admin. – Shane Madden Jul 20 '11 at 18:33
is there any way to get that behavior via command line? Without right-clicking? – naspinski Jul 20 '11 at 18:55
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.