Sunday, October 27, 2013

Start a command prompt (cmd.exe) as SYSTEM


Sometimes you need a command prompt executed as SYSTEM (aka LocalSystem) in order to fix something. The easiest way to do this is to create a service that fires up cmd.exe.

Open a command prompt as Administrator and enter this command:

sc create testsvc binpath= "cmd /K start" type= own type= interact

(The white space after each = are required!)

SC should respond with [SC] CreateService SUCCESS and a warning about the interactive service.

Next, start the service by executing

net start testsvc

You will then see the command prompt with SYSTEM privileges but the net start command will appear to hang. After a while the command will time out with The service is not responding to the control function. As we are misusing cmd.exe as service here the error is expected and can be ignored.

If you close the SYSTEM command prompt by accident, simply execute net start testsvc again.

Once you’re done, delete the service with this command:

sc delete testsvc

No comments:

Post a Comment