Run command in system context

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.

http://technet.microsoft.com/en-us/sysinternals/bb897553

So let start a command prompt as SYSTEM:

Use the command: psexec -s cmd.exe

image

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

image

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 authoritysystem

image

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

image

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

psexec \RemoteComputer -s cmd.exe –accepteula

image

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

image

Again use exit to return to your local system.

+ posts

Table of Contents

Share this post
Search blog posts
Search
Authors
Modern Workplace consultant and a Microsoft MVP in Enterprise Mobility.

Modern Workplace consultant and a Microsoft MVP in Windows and Devices.

Infrastructure architect with focus on Modern Workplace and Microsoft 365 security.

Cloud & security specialist with focus on Microsoft backend products and cloud technologies.

Cloud & security specialist with focus on Microsoft 365.

Cloud & Security Specialist, with a passion for all things Cybersecurity

Cloud and infrastructure security specialist with background in networking.

Infrastructure architect with focus on design, implementation, migration and consolidation.

Infrastructure consultant with focus on cloud solutions in Office365 and Azure.

Modern workplace and infrastructure architect with a focus on Microsoft 365 and security.

follow us in feedly
Categories

Follow on SoMe