How do I open a elevated command prompt using command lines on a normal cmd?
For example, I use runas /username:admin cmd
but the cmd that was opened do
For fans of Cygwin:
cygstart -a runas cmd
I ran into the same problem and the only way I was able to open the CMD as administrator from CMD was doing the following:
powershell -Command "Start-Process cmd -Verb RunAs"
and press EnterYou can use the following syntax, I had the same question and did not think a script should be needed.
runas /profile /user:domain\username cmd
This worked for me, it may be different on your network.
I used runas /user:domainuser@domain cmd
which opened an elevated prompt successfully.
I'm not sure the tool ExecElevated.exe (13KB) will do the job....but it might. Or at least be useful for others with similar needs who came to this page as I did (but I didn't find the solution so I ended up creating the tool myself in .Net).
It will execute an application with elevated token (in admin mode). But you will get an UAC dialog to confirm! (maybe not if UAC has been disabled, haven't tested it).
And the account calling the tool must also have admin. rights of course.
Example of use:
ExecuteElevated.exe "C:\Utility\regjump.exe HKCU\Software\Classes\.pdf"
Dheeraj Bhaskar's method with Powershell has a missing space in it, alt least for the Windows 10 incarnation of Powershell.
The command line inside his sudo.bat should be
powershell.exe -Command "Start-Process cmd \"/k cd /d %cd% \" -Verb RunAs"
Note the extra space after %cd%
;)Frode