There are two common solutions to start a program automatically after the server reboots: use Task Scheduler, or make the program start as a Windows service at bootup. These solutions work for some situations when the program you need to start only needs to run as a background (unseen) process. In this article, we will address how to automatically log in a user and launch a GUI program when the system reboots.
How to Automatically Launch a Program on Startup
First, download a Microsoft provided program called Autologon.exe
After extracting the .zip, run Autologon.exe and enter the credentials for the Windows user you are currently using (for example, Administrator). Click Enable. Now, the Administrator user will log in automatically after the system is rebooted.
Next, open Task Scheduler, and click Create Task… in the right-hand menu. Fill in each of the settings tabs with the options below. In the third tab Actions choose the .exe program you want to run automatically:
General Tab: Fill in a name. Select “Run only when user is logged on.”
Triggers Tab: Click “New…” and then select Begin the task: At log on. Set it to Specific user: and then choose your user (Administrator). Click OK to save the trigger.
Actions Tab: Click “New…” and then select Action: Start a program. Click “Browse…” and browse to the .exe file of the program you want to launch automatically.
The last 2 tabs should remain with the default settings. Click OK to save the new task!
Now, create a second task. This time, we will use exactly the same settings to launch a Windows service. This will disconnect the user from the local desktop after your program is launched, while leaving the user account running and open to access via Remote Desktop Connection or another login.
Use all of the same settings for this task as the previous one, but choose the program C:\Windows\System32\rundll32.exe, and fill in Add arguments (optional) with “user32.dll, LockWorkStation”.
Click OK to save the second task. Now you should have 2 new tasks in Task Scheduler, which you can find under Active Tasks in Task Scheduler:
Confirm the configuration by rebooting your server. Next time you connect with Remote Desktop, or via the local terminal, the program should be open and running.
Note: You can repeat the first task as many times as you need, if additional applications should be started automatically.
This article applies to any Windows system, including:
- Windows Server 2012 R2, 2008 R2, 2003 R2
- Windows 10, 8, 7, Vista, XP
The walk-through above was performed on Windows Server 2012 R2.