monitoring if exe is running otherwise restart it (with task sheduler)

Dear experts,
I am looking for a script that checks if a .exe is still running and otherwise reboots it. I already found a lot on the internet that should work, but I don't get it working. Can someone help me with this? Unfortunately I have very little knowledge of Powershell myself, so I like dummy language. I think I can run this *.ps1 with Taskplanner and check every 15 minutes, or someone has a better option.

With kind regards,

The model below seems very extensive to me but I don't know what to change. As an example I have "notepad".

SETLOCAL EnableExtensions

REM Enter the application information.
SET AppName=Notepad
SET ExeFile=Notepad.exe
SET ExePath=C:\Windows\System32\notepad.exe

REM Select the conditions to kill the application.
REM A value of 1 = Yes, 0 = No
SET KillIfRunning=1
SET KillIfNotResponding=1
SET KillIfUnknownStatus=1

REM Specify when to start the application:
REM 1 = Start only if the process was previous killed.
REM 0 = Start the application regardless.
SET StartOnlyIfKilled=1

SET KillStatus="%TEMP%KillStatus.tmp.txt"
SET Success=0

ECHO Killing existing %AppName% instance...
IF {%KillIfRunning%}=={1} CALL :CheckKillStatus "%ExeFile%" "RUNNING"
IF {%KillIfNotResponding%}=={1} CALL :CheckKillStatus "%ExeFile%" "NOT RESPONDING"
IF {%KillIfUnknownStatus%}=={1} CALL :CheckKillStatus "%ExeFile%" "UNKNOWN"

IF {%StartOnlyIfKilled%}=={1} (
IF {%Success%}=={0} GOTO End
ECHO Restarting %AppName%...
START "%ExeFile%" "%ExePath%%ExeFile%"

IF EXIST %KillStatus% DEL /F /Q %KillStatus%


ECHO Killing with status: %~2
TASKKILL /FI "STATUS eq %~2" /IM "%~1" /F > %KillStatus%
SET /P KillResult= < %KillStatus%
FOR /F "tokens=1,* delims=:" %%A IN ("%KillResult%") DO (
ECHO %%A:%%B
IF /I {%%A}=={SUCCESS} SET /A Success=%Success%+1


Parents Reply Children
No Data