How to open a command prompt running as Local System on Windows 7?

User context is very important. What works for a logged in user may not work for the LocalSystem account. If a process is running as LocalSystem, it is important to test that what you are doing will work when running as LocalSystem. Testing as the logged in user may give incorrect results as the logged in user may have different access rights and permissions.

There used to be many ways to do this, but now in Windows 7 those ways have been cut down.

Here are the two ways I know of that still work, however, only the first way I would recommend:

Method 1 – Using PsExec from Sysinternals

  1. Download psexec from here: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
  2. Extract it.
  3. Open a command prompt and change to the directory where you have psexec and run the following:
    psexec -i -s cmd.exe
    

Method 2 – Using an interactive service

  1. Open a command prompt as administrator (right-click on the cmd.exe shortcut and choose Run as administrator) and run the following:
    sc create CMD binpath= "cmd /K start" type= own type= interact
    sc start "CMD"
    WARNING:  The service testsvc is configured as interactive whose support is being deprecated. The service may not function properly.
    

    A prompt may appear or it may only show down on the start bar and you have to click it to see it. It looks like this:

  2. Click “View Message”.You are now at a local system command prompt.
  3. When you are done, close the command prompt and click return.How to verify that the command prompt is running as Local System?

    1. Run Task Manager and make sure that the cmd.exe process is running as user SYSTEM.

    2. Run SET in your command prompt and make sure the username variable equal your computer name with a $ at the end. For example if you computer is named MyPC1, the username variable would be MyPC1$.

One Comment

  1. Rhyous says:

    Doesn't look like Method 2 works in Windows 8 but method 1 seems to work.

Leave a Reply

How to post code in comments?