Batch (BAT) file to close and restart automatically a program or process


To create a batch file that will close and restart a process we need CloseApp, Sleep and a simple text editor like the default Windows Notepad.

We are going to create actually two batch files, the first one to close the process or program and the second to start it again. The first batch file will also run the second. We need two batch files instead of just one, in order to make sure that the program / process is indeed closed before we attempt to start it again. Here is how you can terminate and restart, for example, the itype (IntelliType) process.

Open your Notepad, then paste the following lines, and save the file as “somename.bat”:

@echo off
start " " "C:\Program Files\closeapp\itype.lnk"
start /wait "" "C:\Program Files\sleep\Sleep.exe" 3
start " " "C:\my documents\mybats\somename2.bat"
exit

The first line uses CloseApp to send a termination command for the IntelliType process, the second line uses Sleep to give 3 seconds to Windows to close the process, and the third line opens the next batch file. On a blank page of the Notepad paste these lines, and save the file as “somename2.bat”:

@echo off
start /wait "" "C:\Program Files\sleep\Sleep.exe" 2
start " " "C:\Program Files\Microsoft IntelliType Pro\itype.exe"
exit

The first line gives some more time to Windows, 2 seconds, and the next line orders Windows to start the IntelliType application. You should change the paths above according to your installations of programs you’d like to terminate and restart. The itype.lnk file is a shortcut to CloseApp.exe you can create inside or outside the CloseApp folder, to terminate the itype process. Here is the target of the shortcut: “C:\Program Files\closeapp\CloseApp.exe” itype.exe

Again, you should change this according to the process you need to close. Finally, create a shortcut in your StartMenu to run the first batch file. You can add it to the favorite Launcher to use it faster.

* Alternative easier solution: Download the free Revitalizer, a light and safe utility that will let you add easily as many applications as you want to restart any of them anytime by just clicking its entry in Revitalizer’s tray menu.

Enjoy!