How to turn a running Windows CMD in Admin?
Emily Wong
I would like to know if it is possible to turn a Windows command into Administration mode after having started the command (and so by using the command).
So I start a normal session:
C:\Users\ME>And FROM this latter session I want to obtain an administrative session, like this one:
C:\Windows\system32>Any Idea ?
3 Answers
CMD needs to be invoked with the required credentials to begin with, as it is not possible to change this from within an existing CMD window. By default, this is as a standard user (even from within an administrative account). To open in elevated mode, see: Elevated Command Prompt
So for all intents and purposes, what you're trying to do isn't possible under windows.
You should use runas.
E.g. runas /user:domainname\username cmd.exe
The /user: shoudl have administrative permissions on the machine.
I'm not sure if there is a way to stay within the same console window (i.e. you'll notice the new cmd.exe will open in a new window) but I think this is related to the fact that windows can only be run under the particular user context so you can't elevate the running application.
You could spawn a second cmd process that has administrator rights through PowerShell, as follows:
powershell "Start-Process cmd.exe -Verb RunAs"