You want to create a Task scheduler that runs a batch file script to kill the current and restart the process.
What is Batch file
Before we continue, let see what is the batch file? According to Wikipedia — A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file. A batch file may contain any command the interpreter accepts interactively and use constructs that enable conditional branching and looping within the batch file, such as IF, FOR, and GOTO labels. The term “batch” is from batch processing, meaning “non-interactive execution”, though a batch file may not process a batch of multiple data.
First, you need to create a batch file with the following script and save it on your local computer. E.g C:\Script
@echo off taskkill /f /im notepad TASKLIST | FINDSTR notepad.exe || start notepad.exe EXIT
- @echo off — Shows the message on a clean line disabling the display prompt. Typically, this line goes at the beginning of the file. (You can use the command without the “@” symbol, but using it hides the executing command to create a cleaner return.)
- taskkill — Kill process on windows system. /f parameter Specifies to forcefully terminate the process(es). And /im parameter Specifies the image name of the process to be terminated. Wildcard ‘*’ can be used to specify all tasks or image names.
- tasklist — Displays a list of currently running processes on either a local or remote machine.
Then, create a task scheduler with the following action:
If you like this article, please share, subscribe or you can follow our Facebook Page and Twitter.