- How to Run a Program as SYSTEM (LocalSystem) Account in Windows
- Method to run a program under the SYSTEM account:
- How to Run Programs as SYSTEM (LocalSystem account)
- Using PsExec.exe from Windows Sysinternals
- Using Advanced Run from Nirsoft
- Run as SYSTEM via the right-click menu
- Using Process Hacker
- Using NirCmd.exe from NirSoft
- Context menu implementation
- Using RunAsSystem from Uwe Sieber
- Context menu implementation
- Using “NSudo” from M2Team
- NSudo: Command-line support
- Context menu addition
- One small request: If you liked this post, please share this?
- About the author
- 2 thoughts on “How to Run a Program as SYSTEM (LocalSystem) Account in Windows”
- Easily Run any Application as a Windows Service with AlwaysUp
- Start your Windows 10/8 or Server 2019/2016/2012 program at boot and keep it running 24×7. Achieve 100% uptime today!
- An easy to use Interface to run any Program as a Windows Service
- Key Features & Benefits of Running an Application as a Windows Service with AlwaysUp
- Run batch file as a Windows service
- 8 Answers 8
How to Run a Program as SYSTEM (LocalSystem) Account in Windows
Many Windows system files, registry keys, and services are owned by the SYSTEM (a.k.a LocalSystem) account, which has a high privilege level. If you need to modify a registry key owned by the SYSTEM account, there are at least two options.
The first option that comes to your mind is to take ownership of the corresponding registry key, assign yourself Full Control permissions. Once the registry key or the values are updated, revert the permissions and ownership to SYSTEM .
There is, however, an easier option. You can run the program — e.g., the Command Prompt or the Registry Editor under the SYSTEM account directly and update the registry values.
This article lists six different methods using which you can run programs under the SYSTEM or LocalSystem account in any version of Windows, including Windows 10. You can also add a Run as SYSTEM right-click menu option for .exe files.
Method to run a program under the SYSTEM account:
Before proceeding, understand that the terms SYSTEM , LocalSystem , and NT AUTHORITY\SYSTEM are one and the same.
How to Run Programs as SYSTEM (LocalSystem account)
To run a program under the SYSTEM account, use one of the following tools:
Using PsExec.exe from Windows Sysinternals
Use PsExec.exe console tool from Microsoft’s Windows Sysinternals to run a program under the SYSTEM context. Follow these instructions:
- Download PsExec from Microsoft Sysinternals.
- Unzip and extract the tool to a permanent folder — e.g., d:\tools
- Open an elevated or admin Command Prompt window.
- To start the Registry Editor under the SYSTEM account, type the following command, and press ENTER :
The above PsExec command-line starts the Registry Editor under LOCALSYSTEM account so that you can modify protected areas in the registry.
Note: If you launch Command Prompt ( cmd.exe ) using PsExec.exe under the SYSTEM account, it spawns a new Command Prompt window. And, any program you launch from that Command Prompt window would run under the SYSTEM (LocalSystem) account, which is a high privileged account. You must be cautious when running programs under the SYSTEM account so that you don’t accidentally run an undesired program as SYSTEM .
Using Advanced Run from Nirsoft
AdvancedRun is a simple tool for Windows that allows you to run a program with different settings that you choose, including – low or high priority, start directory, main window state (Minimized/Maximized), run the program with different user or permissions, Operating system compatibility settings, and environment variables. You can also save the desired settings into a configuration file and then run the program automatically from the command-line with the desired settings.
Using Advanced Run, you also launch a program under SYSTEM or a different user context.
Type in the program name to run and choose SYSTEM user in the Run As dropdown box, and click Run.
You can also create a desktop shortcut to run a program as SYSTEM. Here is the command-line syntax you use:
/RunAs 4 instructs to start the program under the LocalSystem account. The possible value data for the /RunAs switch are below:
- 1 – Run as current user (elevate)
- 2 – Run as current user (no elevation)
- 3 – Run as Administrator (force elevation)
- 4 – Run as SYSTEM
- 8 – Run as TrustedInstaller
This starts the program under the LocalSystem account, which you can verify in the Task Manager Details tab.
Run as SYSTEM via the right-click menu
To launch a program under the SYSTEM account (with Advanced Run) from the right-click context menu, make a .reg file from the following contents and run the file.
Change the path to AdvancedRun.exe in the .reg file if necessary.
This adds the Run as SYSTEM command to the right-click menu for .exe files and its shortcuts.
Using Process Hacker
Process Hacker is an excellent process manager that looks similar to Sysinternals Process Explorer. This tool has a unique feature that allows you to launch a program under the same account as a running process or service.
- Run Process Hacker as administrator.
- Locate a program or service which is currently running under NT AUTHORITY\SYSTEM .
- Right-click on the process, click Miscellaneous, and click Run as this user…
Now the program (e.g., cmd.exe) would run as SYSTEM ( NT AUTHORITY\SYSTEM )
The above method can also be used to launch any program under TrustedInstaller.
Using NirCmd.exe from NirSoft
NirCmd is a multipurpose command-line tool which we’ve covered in this site before.
NirCmd can start a program elevated as well as launch it under the SYSTEM account.
Use this command-line to start the Registry Editor elevated and under the SYSTEM account:
Context menu implementation
Make a .reg file from the following contents and run the file.
Using RunAsSystem from Uwe Sieber
RunAsSystem (from Uwe Sieber) is a console tool that launches a program under the SYSTEM account or context. It also passes the window style and its process priority to the executed process by default. You can override the window size as well as the child process priority using command-line arguments. Uwe Sieber is the one who developed the famous USB Drive Letter Manager program.
It waits for the started process to end and then passes back its return code (aka errorlevel). However, in a batch file, you have to add start /wait .
Usage:
Examples:
Context menu implementation
Make a .reg file from the following contents and run the file.
The above .reg file adds a Run as SYSTEM command in the right-click menu for .exe files. The .reg file assumes that the file RunAsSystem.exe is placed under the d:\tools folder. If not, alter the path accordingly in the .reg file.
Using “NSudo” from M2Team
NSudo (GitHub) is a similar portable utility like Advanced Run, except that it is not digitally signed. It can launch programs under SYSTEM, Current User, Current Process, or the TrustedInstaller account. We’ve earlier seen how to use NSudo to launch programs as TrustedInstaller.
Select the mode (System) from the dropdown, type in the executable path, and click Run.
Optionally, you can also add a predefined set of programs or commands in the Open: drop-down list box by editing the file named NSudo.json located in the same folder as the executable.
To run a program under the SYSTEM context using NSudo command-line, use this syntax:
See below for the full list of command-line arguments supported by this utility.
NSudo: Command-line support
Context menu addition
- Run NSudo with -Install parameter. It copies NSudo to the Windows directory and adds the context menu.
- To remove the context menu, run NSudo with the -Uninstall parameter. It removes NSudo from the Windows directory and the context menu.
Editor’s Pick: Advanced Run for GUI (and CLI), and PsExec for CLI.
One small request: If you liked this post, please share this?
About the author
Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.
Microsoft → Windows → How to Run a Program as SYSTEM (LocalSystem) Account in Windows
2 thoughts on “How to Run a Program as SYSTEM (LocalSystem) Account in Windows”
This is a really useful article and information. Thank you for that!
I use this feature at the login screen by renaming a few files while Windows is offline. While this is a handy feature for technicians like myself, shouldn’t this be a security issue that Microsoft addresses?
Easily Run any Application as a Windows Service with AlwaysUp
Start your Windows 10/8 or Server 2019/2016/2012 program at boot and keep it running 24×7. Achieve 100% uptime today!
When run as a Windows Service, your application can start automatically without someone having to log on, survive user logons/logoffs, and run entirely without user intervention. No programming is required.
And best of all, after years of constant refinement based on client feedback and many thousands of installations on a variety of PCs, AlwaysUp remains a trusted, reliable solution for many large and small businesses worldwide.
Take advantage of our risk-free 30-day trial and find out for yourself!
An easy to use Interface to run any Program as a Windows Service
AlwaysUp‘s intuitive GUI makes it very easy to configure any application as a Windows Service. Just specify two key items (a name and the path to your application) and you are on your way! Come back for the advanced features later.
Key Features & Benefits of Running an Application as a Windows Service with AlwaysUp
- Ensure that any application (.exe, batch file, .com, .pif, script, shortcut, perl script, java app, php, delphi, vb, etc.) runs 24×7
- Very easy to use — install your application as a Windows Service in just a few seconds!
- Able to automatically start your application when your computer boots, to run when no user is logged in and to run despite logon/logoffs — all to guarantee uptime without manual user intervention
- Converts both GUI and non-GUI applications to run as Services
- Constantly monitors your application and restarts it whenever it fails
- Secure — no need to auto-logon to Windows
- Able to detect and restart «misbehaving» applications that hang, hog the CPU, or consume too much memory
- Able to restart your application (or reboot the computer) at a scheduled time
- Able to boost your application’s priority to ensure that it gets preferential treatment on the host computer
- Emails you with details of crashes, restarts and other problems
- Supports the integration of your own custom «sanity check» utilities, executed regularly to test if your application is functioning normally or not
- Automatically dismisses common «Application error» dialog boxes that prevent crashed applications from fully exiting
- The intuitive GUI makes it easy to set up your application as a Windows Service, but no GUI is necessary once your application has been configured
- Supports powerful automation, to automatically dismiss custom dialogs, fill in forms, etc. from your program running as a Windows Service
- Reports all activities to the Windows Event Log
- Works flawlessly in all virtual environments (VMWare, Virtual PC, etc.)
- Very efficient; demands minimal CPU & memory resources
- Compatible with Session 0 Isolation in Windows Server 2019/2016/2012 and Windows 10/8
- Control AlwaysUp applications from your web browser using our free add-on program, AlwaysUp Web Service
- Free, courteous technical support via email or phone
- Site, OEM and Volume licensing available to suit your needs
- Branding for Enterprise, Site and OEM licensees
- No programming required
- Future-proof; tailored for Windows 10 & Server 2019 and has earned the «Certified for Windows Server 2012» logo (and others) from Microsoft.
- Trusted by many of the world’s most recognizable companies
- Robust and stable, with an installed base in the tens of thousands
But perhaps most important of all, AlwaysUp was designed and implemented by Senior Software Engineers with over 25 years of real-world experience developing robust, mission-critical applications. Our software is of the highest quality, and we stand by it without reservation.
Run batch file as a Windows service
In order to run one application, a batch file has to be kicked off (which does things like start Jetty, display live logs, etc). The application will work only if this batch file is running. I am hence forced to have this batch file running and not logout from the Windows server.
Can this batch file be run as a service? I am experimenting with one of the suggestions from a similar question.
8 Answers 8
NSSM is totally free and hyper-easy, running command prompt / terminal as administrator:
then a dialog will appear so you can choose where is the file you want to run.
Why not simply set it up as a Scheduled Task that is scheduled to run at start up?
There’s a built in windows cmd to do this: sc create. Not as fancy as nssm, but you don’t have to download an additional piece of software.
- start=demand means you must start the service yourself
- whitespace is required after =
- I did encounter an error on service start that the service did not respond in a timely manner, but it was clear the service had run the .bat successfully. Haven’t dug into this yet but this thread experienced the same thing and solved it using nssm to install the service.
No need for extra software. Use the task scheduler -> create task -> hidden. The checkbox for hidden is in the bottom left corner. Set the task to trigger on login (or whatever condition you like) and choose the task in the actions tab. Running it hidden ensures that the task runs silently in the background like a service.
Note that you must also set the program to run «whether the user is logged in or not» or the program will still run in the foreground.
On Windows 2019 Server, you can run a Minecraft java server with these commands:
sc create minecraft-server DisplayName= «minecraft-server» binpath= «cmd.exe /C C:\Users\Administrator\Desktop\rungui1151.lnk» type= own start= auto
The .lnk file is a standard windows shortcut to a batch file.
— .bat file begins —
java -Xmx40960M -Xms40960M -d64 -jar minecraft_server.1.15.1.jar
All this because:
service does not know how to start in a folder,
cmd.exe does not know how to start in a folder
Starting the service will produce «timely manner» error, but the log file reveals the server is running.
If you need to shut down the server, just go into task manager and find the server java in background processes and end it, or terminate the server from in the game using the /stop command, or for other programs/servers, use the methods relevant to the server.
As Doug Currie says use RunAsService.
From my past experience you must remember that the Service you generate will
- have a completely different set of environment variables
- have to be carefully inspected for rights/permissions issues
- might cause havoc if it opens dialogs asking for any kind of input
not sure if the last one still applies . it was one big night mare in a project I worked on some time ago.
While it is not free (but $39), FireDaemon has worked so well for me I have to recommend it. It will run your batch file but has loads of additional and very useful functionality such as scheduling, service up monitoring, GUI or XML based install of services, dependencies, environmental variables and log management.
I started out using FireDaemon to launch JBoss application servers (run.bat) but shortly after realized that the richness of the FireDaemon configuration abilities allowed me to ditch the batch file and recreate the intent of its commands in the FireDaemon service definition.
There’s also a SUPER FireDaemon called Trinity which you might want to look at if you have a large number of Windows servers on which to manage this service (or technically, any service).
Install NSSM and run the .bat file as a windows service. Works as expected