Search This Blog

Wednesday, January 14, 2015

Run command in system context

Sometimes I need to test program, scripts and so on running in system context, just to see if its working.

For this I always use an old friend from sysinternals PSEXEC.

So let start a command prompt as SYSTEM:

Use the command: psexec -s cmd.exe


First time you start PSEXEC you must accept License Terms or use the parameter –accepteula to suppress the display of the license dialog:


And now we have a command prompt in SYSTEM context where we can test for example our script to see if if works in SYSTEM context.

This would be nice to try before running it in a SCCM Task Sequence or a Scheduled Task running in SYSTEM context.

To prove that we actual are running as SYSTEM we can try the command whoami.

And as you can see here it should reply nt authority\system


Use the command EXIT to return to the original command prompt.


PSEXEC will also work remote so let try the same on a remote computer:

psexec \\RemoteComputer -s cmd.exe –accepteula


And lets see on which computer we are running on by using the command HOSTNAME:


Again use exit to return to your local system.

No comments:

Post a Comment