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
- Download psexec from here: http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
- Extract it.
- 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
- 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:
- Click “View Message”.You are now at a local system command prompt.
- 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.
SETin 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$.