End process and open again by.bat

My problem is currently the following, I have an executable that has the function of employee access control, but due to some problem in this process it usually stops responding, with this I created a bat to finish the process, but it is necessary to click on bat wait for it to complete and after that I opened the control executable again.

Wanted an idea of how to create a bat that finishes the process and after that open the executable again, that is possible?

.bat:

taskkill /f /im ACCA.exe

Executable path:

c:\exe\ACCA.exe

Since now I thank any and all help,

 3
Author: Bulfaitelo, 2019-02-06

2 answers

Run the following code bat:

taskkill /F /IM ACCA.exe
ping 127.0.0.1 -n 10
start c:\exe\ACCA.exe

The ping serves as a sleep (I did not find the function of sleep in the bat) for some cases of applications that are heavy and need a certain time to terminate all their services, the -n 10 parameter indicates that the system must ping the ip( you can use another ip) an amount of 10 times before opening the executable again.

@Edited

I use o command timeout /t 10 quoted in the response Edited of the Laércio to replace the command ping (used only for waiting for the total completion of the desired application) and it worked, you can replace the line ping 127.0.0.1 -n 10 by the command timeout /t 10 if you want to wait 10sec(in addition to that you can end the wait by pressing on any key), rasoable time to my view to finish any application. I recommend using timeout, since ping was not actually done to pause execution. It is at your discretion to use ping or timeout.

Note : I don't know for what reason, but when chatting with Bulfaitelo in the Chat, we saw that by creating a shortcut of the executable c:\ACCA\ACCA.exe and adding the path of that shortcut to the command start, the command worked as expected.

 4
Author: RXSD, 2019-02-06 15:02:31

You have already placed the command necessary to terminate the program, which is the taskkill, now only missing by a start before the file path to boot it again.

Your batch would look like this:

taskkill /f /im ACCA.exe
start c:\exe\ACCA.exe

If you want it to wait a few seconds before starting the program you can put the command timeout /t 10 (to wait 10 seconds), in which case the batch would look like this:

taskkill /f /im ACCA.exe
timeout /t 10
start c:\exe\ACCA.exe

Saves this as [filename].bat and puts on a scheduled task in the Windows.

 4
Author: Laércio Lopes, 2019-02-06 12:09:00