How To Launch An EXE Process With Engine By Using Windows Task Scheduler

Follow

For exemplification purposes we'll be using Notepad.exe as a process that will be started and stopped. 

1. As a first step, you will need to create a shortcut for the executable in a new folder:

mceclip0.png

2. Create a Stop_Notepad.cmd file in which you enter:

taskkill /FI "IMAGENAME eq NOTEPAD*" /T /F

mceclip6.png

3. Next, create a new task in Task Scheduler (make sure Run with highest privileges is selected and also that the Configure for has the right OS:

mceclip1.png

4. Next under Actions tab select the shortcut that was created at step 1:

mceclip2.png

5. Under Conditions, make sure both options under Power are unchecked:

mceclip3.png

6. Adjust the recovery settings based on user needs:

mceclip4.png

7. Next click on OK and enter the credentials under which the task will run:

mceclip5.png

Next in AMC, you need to create 4 tasks to start/stop the application and to enable/disable the task:

8. The first one will be a Pre Stop task to disable the task that was created in TS with the following command (/TN should be followed by the Task name from Task Scheduler):

schtasks /change /disable /TN Neverfail\Start_Notepad

mceclip7.png

9. The next task will be a Pre Stop task that will point to the Stop_Notepad.cmd file:

mceclip9.png

10. The third task will be a Post Start, to enable the TS task, with the command:

schtasks /change /enable /TN Neverfail\Start_Notepad

mceclip10.png

11. The last task will be a Post Start task to run the task for Notepad, with this command:

schtasks /run /I /TN Neverfail\Start_Notepad

mceclip11.png

12. Next you do an inclusion filter for the scripts, to replicate the files to the Secondary server

13. For System Plugin, make sure it is setup to protect Task Scheduler:

mceclip12.png

At the end these are the four tasks:

mceclip13.png

IMPORTANT NOTE: if the application fails to interact with the Desktop, you will need to change the user account setting to "Run only when user is logged on"

mceclip14.png

 

 

 

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.