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.
Best Answer
You can use the Start-Process cmdlet in Powershell with the RunAs verb. More here: http://technet.microsoft.com/en-us/library/dd347667.aspx