Keeping critical applications running is essential for productivity, servers, and background services. Windows Task Scheduler provides a built-in way to automatically start a program if it stops running without needing third-party software.
This post explains how to configure Windows Task Scheduler to check whether a program is running and start it automatically if it isn’t.
Automatically Start a Program If It’s Not Running
Getting Started
There are various approaches to check an application's running status and start the application or program if necessary. However, the approach we will follow relies on using Windows Task Scheduler together with a small script to monitor whether a specific program is running. Since Task Scheduler cannot directly detect running processes, a batch file or PowerShell script is used to perform this check.
The script periodically scans the list of active processes, and if the target program is not found, it automatically launches the application. Task Scheduler is then configured to run this script at regular intervals, such as every few minutes, ensuring continuous monitoring. This setup creates a simple yet effective self-recovery mechanism that keeps the program running without user intervention.
Before continueing let's have a brief introduction to Windows Task Scheduler. Windows Task Scheduler is a built-in system utility in Microsoft Windows that allows users to automate tasks based on specific triggers and conditions. It enables programs, scripts, or system commands to run automatically at scheduled times, during system events, or in response to particular actions such as user logon or system startup.
Task Scheduler is widely used for routine maintenance, background processing, and system management tasks because it operates reliably in the background without user interaction. By providing flexible scheduling options, security controls, and detailed execution settings, Task Scheduler serves as a powerful tool for automating processes and ensuring critical applications and services run consistently.
Why Use Task Scheduler for This?- Automatically recover crashed applications
- Ensure background tools or scripts are always running
- Avoid manual restarts
- Use native Windows tools (no extra software)
Create a Batch Script to Check the Program
Windows Task Scheduler cannot directly check running processes, so we use a batch file. Create a batch file using following sample batch script.
@echo off
tasklist | find /i "notepad.exe" >nul
if errorlevel 1 (
start "" "C:\Windows\System32\notepad.exe"
)
How This Works
- tasklist lists running processes
- find searches for the program name
- If not found, start launches the program
- Open Notepad
- Paste the code above
- Save as, For example
StartNotepadIfNotRunnint.bat(store it in safe location).
@echo off
set LOGFILE=%~dp0NotepadLauncher.log
echo [%date% %time%] Script started >> "%LOGFILE%"
REM Check if Notepad is running
tasklist /FI "IMAGENAME eq notepad.exe" | find /I "notepad.exe" >nul
if errorlevel 1 (
REM Notepad not running, try to start it
echo [%date% %time%] Notepad not running. Attempting to start... >> "%LOGFILE%"
start "" notepad.exe
if errorlevel 1 (
echo [%date% %time%] ERROR: Failed to start Notepad. >> "%LOGFILE%"
) else (
echo [%date% %time%] Notepad started successfully. >> "%LOGFILE%"
)
) else (
echo [%date% %time%] Notepad is already running. >> "%LOGFILE%"
)
echo [%date% %time%] Script finished. >> "%LOGFILE%"
How it works:
%~dp0— refers to the folder where the batch file is located.start "" notepad.exe— opens Notepad in a separate window.>> "%LOGFILE%"— appends log messages to >NotepadLauncher.log.errorlevel— checks if the command was successful (0 = success, 1+ = failure).
@echo off
REM ===== Configuration =====
set APPNAME=MyApp.exe
set APPPATH="C:\Path\To\MyApp.exe"
set LOGFILE=%~dp0AppLauncher.log
echo [%date% %time%] Script started >> "%LOGFILE%"
REM Check if the application is running
tasklist /FI "IMAGENAME eq %APPNAME%" | find /I "%APPNAME%" >nul
if errorlevel 1 (
REM Application not running, try to start it
echo [%date% %time%] %APPNAME% not running. Attempting to start... >> "%LOGFILE%"
start "" %APPPATH%
if errorlevel 1 (
echo [%date% %time%] ERROR: Failed to start %APPNAME%. >> "%LOGFILE%"
) else (
echo [%date% %time%] %APPNAME% started successfully. >> "%LOGFILE%"
)
) else (
echo [%date% %time%] %APPNAME% is already running. >> "%LOGFILE%"
)
echo [%date% %time%] Script finished. >> "%LOGFILE%"
Create a New Scheduled Task
- Click Create Task (not “Basic Task”)
- On the General tab:
- Name: Auto Start Notepad
- Check Run whether user is logged on or not
- Check Run with highest privileges
- Configure for your Windows version
- Set the Trigger
- Go to the Triggers tab
- Click New
- Configure:
- Begin the task: On a schedule
- Set Daily
- Check Repeat task every: Choose 5 minutes (or your preference), choose Indefinitely
- Click OK
- Set the Action
- Go to the Actions tab
- Click New
-
Configure:
- Action: Start a program
- Program/script:
C:\Scripts\Check_Notepad.bat
- Click OK
- Configure Conditions
- Go to the Conditions tab
- Uncheck:
- “Start the task only if the computer is on AC power” (if on a laptop)
- Adjust network conditions if needed
- Configure Settings
- Go to the Settings tab
- Recommended options:
- Allow task to be run on demand
- Run task as soon as possible after a scheduled start is missed
- If the task fails, restart every: 1 minute
- Save and Test
- Click OK
- Enter your Windows credentials if prompted
- Right-click the task → Run
- Close the program manually and wait for the trigger interval
- Confirm that it restarts automatically
Summary
Windows Task Scheduler is a powerful and free way to ensure important programs stay running. By combining a simple script with scheduled checks, you can automatically restart applications whenever they stop
Thanks