# Program to run in background to turn back on .exe program that shuts down

Is there a Windows program that check (every 5 minutes or so) to see if an .exe process is running, and if not, turn it back on?

The Problem: My latest update of Plex turns itself off after about 6 hours of running and it needs to be running 24/7.

I've tried to debug the problem in the Plex forums. Lots of people have the problem, no once has solved it.

I thought a temporary work around would be a program that runs in the background and monitors the Plex .exe file. If it ever turns off, it restarts the program.

Does something like this exist?

• Best is that Plex works correctly 24/7, when this is not possible create a scheduled task that runs every x minutes and checks whether Plex (or the requested program) still runs when this is not the case start the program. – albert Jun 14 at 15:52
• Is Plex really gone (not visible in task manager at all) or does it hang (visible in task manager but does not react)? – Thomas Weller Jun 14 at 17:42
• Thomas, Yes, Plex does turn itself off. Is taken off of task manager even as a background process. I see your solution and will give it a try. Thanks. – ScottOS Jun 15 at 17:12

If Plex is gone (like crashed; no longer running) it can be achieved by built-in mechanisms of Windows. All you need is a file with .cmd extension and this content:

@echo off

:checkagain
REM Check if Plex is running
tasklist | findstr "plex" | find /c /v "" > NUL

REM If found in the task list, this will have errorlevel 0
if errorlevel 1 goto startplex

REM Wait for 60 seconds to check again
REM Note: you need to set n to seconds+1
ping localhost -n 61 > NUL

goto checkagain

:startplex
start "" "c:\path\to\plex\plex.exe" "argument"
REM Give it some time to start up before checking again
ping localhost -n 11 > NUL
goto checkagain


In here,

• "plex" is the search term. I don't have Plex, so I don't know exactly what the search string should be. Run tasklist once, check what Plex is named, then try tasklist | findstr "plex" (or whatever search term you like) and adapt that search string in the CMD file.
• > NUL suppresses the output.
• "c:\path\to\plex\plex.exe" is the executable you need to run in order to restart Plex. Quotation marks help in case of a path with spaces.
• "argument" is anything Plex might need to start properly. Remove this, if it needs no additional information.