Windows Task Scheduler: How is a startup task started and then the program is closed?

I am creating a specific task.

I need to track when the program ends, draw up a report and analyze it. So, I want to create a schedule for it.

For example, I have a process named testing.exe

and I want to test it after the job completes. I have a file analyze.bat

. I just need to start something, right after it testing.exe

exits and closes.

I cannot change anything in the program code, so I believe that the task scheduler is the only way.

help me please

+3


source to share


1 answer


The Task Scheduler isn't even required for this! This can only be done with a package!

@echo off
set batdir=____________
:begin
tasklist /FI "IMAGENAME eq testing.exe" 2>NUL | find /I /N "testing.exe">NUL
if "%ERRORLEVEL%"=="0" goto start
goto begin
:start
tasklist /FI "IMAGENAME eq testing.exe" 2>NUL | find /I /N "testing.exe">NUL
if "%ERRORLEVEL%"=="0" goto start
start %batdir%\analyze.bat

      



Just replace _________ with the analyt.bat directory and it should work. What it does: It first waits for test.exe to run. If it was running or was already enabled, it switches and now waits for the .exe testing to complete. Once it closes, it will launch the analyt.bat which is exactly what you want, without the need for a task scheduler. Hope I helped!

0


source







All Articles