Programs started from a Remote Desktop session stop when that session signs out and do not come back after a reboot. Bots, game servers, Node.js or Python applications, data collectors and trading tools should instead start automatically with Windows and restart by themselves if they crash. This guide shows three reliable ways to do that on Windows Server: Task Scheduler, the free service wrapper NSSM, and Windows' own service recovery settings.
| Method | Best for | Restarts on crash | Needs a logged-in desktop |
|---|---|---|---|
| Task Scheduler "At startup" | Scripts and console programs | Yes (retry settings) | No |
| NSSM service | Long-running console apps (Node.js, Python, Java, game servers) | Yes, immediately | No |
| Auto-logon + Startup folder | Programs that need a visible window or GUI | No | Yes |
Open taskschd.msc and choose Create Task (not "Basic Task"):
The same task from PowerShell:
$action = New-ScheduledTaskAction -Execute "C:\apps\collector\collector.exe" -WorkingDirectory "C:\apps\collector"
$trigger = New-ScheduledTaskTrigger -AtStartup
$trigger.Delay = "PT30S"
$settings = New-ScheduledTaskSettingsSet -RestartCount 999 -RestartInterval (New-TimeSpan -Minutes 1) `
-ExecutionTimeLimit ([TimeSpan]::Zero) -StartWhenAvailable
Register-ScheduledTask -TaskName "Collector" -Action $action -Trigger $trigger -Settings $settings `
-User "SYSTEM" -RunLevel Highest
Start-ScheduledTask -TaskName "Collector"
Get-ScheduledTaskInfo -TaskName "Collector" # LastTaskResult 0 = success
NSSM (the Non-Sucking Service Manager) wraps any executable as a real Windows service, restarts it immediately if it exits and can write its console output to log files. Download it from nssm.cc, copy nssm.exe (from the win64 folder) to C:\Windows\System32, then:
# Example: a Node.js application
nssm install MyApp "C:\Program Files\nodejs\node.exe" "C:\apps\myapp\server.js"
nssm set MyApp AppDirectory C:\apps\myapp
nssm set MyApp AppStdout C:\apps\myapp\logs\out.log
nssm set MyApp AppStderr C:\apps\myapp\logs\error.log
nssm set MyApp AppRotateFiles 1
nssm set MyApp AppRotateBytes 10485760
nssm set MyApp Start SERVICE_AUTO_START
nssm start MyApp
nssm status MyApp
nssm restart MyApp
nssm edit MyApp # graphical editor for all settings
nssm remove MyApp confirm
For a Python script use the path of python.exe with the script as the argument; for Java use java.exe with -jar app.jar. If the program needs access to network shares or a user profile, set the account on the Log on tab of nssm edit instead of LocalSystem.
For a program that already installs itself as a service (a database, a game server, an agent), tell Windows to restart it automatically when it fails:
# Restart after 5 seconds on the first three failures; reset the failure counter after one day
sc.exe failure "MyService" reset= 86400 actions= restart/5000/restart/5000/restart/5000
sc.exe failureflag "MyService" 1
sc.exe config "MyService" start= auto
sc.exe qfailure "MyService"
The same options are on the Recovery tab of the service in services.msc.
Services run in an isolated session without a visible desktop, so GUI programs that must show a window (some trading terminals, game clients, automation tools) will not work as services. For these, enable automatic sign-in for a dedicated user with Microsoft's Sysinternals Autologon tool (it stores the password encrypted), put a shortcut to the program in shell:startup for that user, and disconnect rather than sign out when you leave the Remote Desktop session. Also exclude that user from automatic sign-out time limits.
Check that Start in (or the NSSM AppDirectory) is set: many programs look for config files relative to the working directory. Also check the program's own logs, and for NSSM the AppStderr file.
Run the exact same command manually in a PowerShell window to see the error. For services, also look in Event Viewer → Windows Logs → System and Application.
Yes. Startup tasks and automatic services start again after every reboot, which is exactly why they are better than an open Remote Desktop session. See managing Windows Update to control when reboots happen.
Still stuck after following these steps? Open a support ticket and the IMIDC 24/7 technical team will help. Include the server IP, the Windows Server version, the program you want to run and the exact error or event log entry so we can pinpoint the issue faster.