Reputation: 11
I have searched and searched and this is the closest code I have found:
@echo off
:loop
C:\CryptoCurrency\nexus_cpuminer\start.bat
timeout /t 30 >null
taskkill /f /im nexus_cpuminer.exe >nul
goto loop
A few things: notice the start.bat. The .exe I need to launch has to start via the .bat file because the .bat file contains information the .exe needs.
Secondly, the .exe launches a CMD prompt window which shows me what's going on. (keep this in mind because this is not your normal .exe, I WANT that CMD prompt window to close when it's KILLED)
I am aware I have it set for 30 seconds. I'm just testing right now. I'd like to set it for 4 hours before the kill command is called. Also, I'd like to set a "delay" of 30 seconds before the whole process starts over. I am running Windows 7 x 64.
Upvotes: 1
Views: 2014
Reputation: 67296
You must change the name of the second Batch file to other name (i.e. starter.bat
) and execute it via the start
internal command in order to execute it in parallel:
@echo off
:loop
start "" cmd /C "C:\CryptoCurrency\nexus_cpuminer\starter.bat"
timeout /t 30 >null
taskkill /f /im nexus_cpuminer.exe >nul
goto loop
The last line in starter.bat
file must be the execution of nexus_cpuminer.exe
, so when it is killed via taskkill
, the .bat file ends immediately.
Another simpler approach is to directly execute nexus_cpuminer.exe
in this Batch file, via start "" cmd /C nexus_cpuminer.exe
command, so this process be opened in its own cmd.exe window.
Upvotes: 1
Reputation: 38719
If you CALL start.bat, it will return to your 'calling' script. If you give start.bat a TITLE, you can /FIlter your TASKKILL command to EQ that WINDOWTITLE
Upvotes: 0