8
3
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.
XP doesn't have UAC so the question is not relevant to it – nponeccop – 2014-12-06T01:20:10.040
@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 – 2018-04-18T13:47:05.950
Perfect, thank you. I updated the question with a working example. – jwd – 2012-05-03T23:56:45.530
Any equivalent on Windows XP? – Maxbester – 2013-06-07T12:31:50.890
Powershell is available for XP. – uSlackr – 2013-06-07T19:19:20.723