In Win7, a user can right-click on a program and choose 'Run as administrator'. You get a popup, but do not have to enter the administrator password.

I would like to get the same functionality, but from the commandline - in particular, from inside a .bat file.

I am aware of the built-in runas command, but I have not found a way to use that that doesn't end up asking for a password at some point.

I am also aware of the Process.StartInfo.Verb = "runas"; method, which does exactly what I want, but requires me creating a custom .NET app.

Is there any way, using only built-in commandline tools in Win7, to accomplish this?

Update: Thanks to uSlackr, I worked out this command:

powershell Start-Process cmd.exe -Verb RunAs

Of course, the cmd.exe is just a placeholder.


You can use the Start-Process cmdlet in Powershell with the RunAs verb. More here: http://technet.microsoft.com/en-us/library/dd347667.aspx

  • Perfect, thank you. I updated the question with a working example. – jwd May 3 '12 at 23:56
  • Any equivalent on Windows XP? – Maxbester Jun 7 '13 at 12:31
  • Powershell is available for XP. – uSlackr Jun 7 '13 at 19:19
  • XP doesn't have UAC so the question is not relevant to it – nponeccop Dec 6 '14 at 1:20
  • @nponeccop I assume the motivation for wanting to run under Windows XP is to let a single script run on both Windows 7 and Windows XP, not have one path for Windows 7 that has PowerShell and UAC and a second path for Windows XP that has no PowerShell and no UAC. – Damian Yerrick Apr 18 '18 at 13:47

Simply run the cmd.exe as administrator.

The keyboard shortcut for this is [shift] + [enter] after you have selected the commandline from the start menu. A UAC window should pop up.


Run everything as Admin

Not recommended for everyday usage, but there is also a built in administrator account that you can activate in windows that will simply run any and all applications as root. In an administrative cmd:

net user administrator /active:yes

Change that to '/active:no' if you want to disable the account. A brief intro here.

  • Regarding your first suggestion: Sorry, I was not clear. I want to do this from inside a .bat file (question updated). – jwd May 3 '12 at 23:50
  • Regarding your second suggestion: I ran this, and got "System error 5 has occurred. Access is denied." – jwd May 3 '12 at 23:50
  • Even running cmd.exe as admin? – A. Hayes May 4 '12 at 21:59
  • 1
    The whole point of this question is that I am running this command as a non-admin user and I want to temporarily elevate permissions. – jwd May 5 '12 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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