Running CMD as local system

Many times I need to troubleshoot problems with services.
You cannot make a runas with Local System so I searched for a workaround.

Creating an interactive service that just runs CMD.EXE was a good idea but SCM (Service Control Manager) killed the process after a few seconds because it wasn't able to create a communication channel with the service (obviously cmd hasn't got..).

The solution is to ask the service to start another CMD during these few seconds.

sc create MyShell binpath= "cmd /K start" type= own type= interact
sc start MyShell (it will return error 1053 but will open a CMD window)
sc delete MyShell


Note: when you run it on a remote desktop connection, the CMD window will open into console session.
Share on Google Plus

About Vittorio Pavesi

    Blogger Comment
    Facebook Comment

0 commenti: