Run a Program at Startup on Windows Server: Task Scheduler
The most reliable way to start a program automatically on Windows Server is Task Scheduler with an “At startup” trigger: the program launches as the system boots, even with no user signed in. For applications that need a desktop, the Startup folder or the registry Run key works better. Here are all three options.
Which method to choose
| Method | When it runs | User logon required |
|---|---|---|
| Task Scheduler (At startup) | At OS boot | No |
| Task Scheduler (At log on) | At sign-in | Yes |
| Startup folder | At user sign-in | Yes |
| Registry Run key | At user sign-in | Yes |
For services and background processes that run around the clock, use Task Scheduler with “At startup”. For applications with a user interface, use a logon-time launch.
Method 1. Task Scheduler (recommended)
Through the graphical interface
- Open Task Scheduler (
taskschd.msc). - On the right click Create Task (not Basic Task — this gives more options).
- On the General tab set a name, select Run whether user is logged on or not and tick Run with highest privileges.
- On the Triggers → New tab choose At startup.
- On the Actions → New tab enter the path to the program (for example
C:\apps\myapp.exe). - Click OK and enter the password of the account the task will run under.
Through PowerShell
The same task in one sequence of commands:
$action = New-ScheduledTaskAction -Execute "C:\apps\myapp.exe"
$trigger = New-ScheduledTaskTrigger -AtStartup
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "MyAppAutostart" -Action $action -Trigger $trigger -Settings $settings -RunLevel Highest -User "SYSTEM"
Check that the task was created:
Get-ScheduledTask -TaskName "MyAppAutostart"
Run it manually to test:
Start-ScheduledTask -TaskName "MyAppAutostart"
Method 2. The Startup folder
The program starts when a specific user signs in. Open the Startup folder:
shell:startup
(for all users, shell:common startup). Put a shortcut to the program there. You can create the shortcut programmatically from PowerShell:
$startup = [Environment]::GetFolderPath('Startup')
$shell = New-Object -ComObject WScript.Shell
$shortcut = $shell.CreateShortcut("$startup\MyApp.lnk")
$shortcut.TargetPath = "C:\apps\myapp.exe"
$shortcut.Save()
Method 3. The registry Run key
A value under the Run key launches the program when the user signs in:
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "MyApp" -Value "C:\apps\myapp.exe"
For all users, use the HKLM: hive instead of HKCU:.
Frequently asked questions
The program does not start at boot — why?
Most often the application needs an interactive desktop while the task is set to “Run whether user is logged on or not”. GUI programs like that are better launched with an At log on trigger or from the Startup folder.
How do I start a program as administrator automatically?
Enable Run with highest privileges in Task Scheduler. The task then starts elevated with no UAC prompt.
Why is Task Scheduler better than the Startup folder?
The scheduler can start processes before any user signs in, with the rights you specify, on a schedule and with restart-on-failure. The Startup folder only works after a sign-in.
How do I remove a program from autostart?
For a task: Unregister-ScheduledTask -TaskName "MyAppAutostart" -Confirm:$false. For the registry: Remove-ItemProperty. For the folder, delete the shortcut from shell:startup.
Need a server that keeps your services running around the clock? Take a Windows VPS or review the VPS hosting plans.