Here's my script in my bat file:
cd "C:\Program Files (x86)\Steam\Steamapps\common\F13game\"
Start F13theGameRemap.exe
cd "C:\Program Files (x86)\Steam\steamapps\common\F13Game\SummerCamp\Binaries\Win64\"
Start /WAIT SummerCamp.exe
Start /WAIT Taskkill /f /im F13theGameRemap.exe
exit
All I want is to run the first program, then the 2nd. When the 2nd program "summercamp.exe" exits, i want the first program "F13thegameremap.exe" to exit.
The way this script works now is that Taskkill immediately ignores the start /wait command of summercamp.exe and closes F13theGameRemap.exe immediately.
How do I fix this?
Something like this:
#Echo off
Cd /D "C:\Program Files (x86)\Steam\Steamapps\common\F13game\"
Start F13theGameRemap.exe
Cd /D "C:\Program Files (x86)\Steam\steamapps\common\F13Game\SummerCamp\Binaries\Win64\"
Set "App2=SummerCamp.exe"
Start /WAIT %App2%
:loop
Timeout /t 1 >NUL
tasklist.exe /FI "ImageName eq %App2%" /NH |find /i "%App2%" >NUL && Goto :loop
Start /WAIT Taskkill /f /im F13theGameRemap.exe
The :loop will check with 1 second delay if %App2% aka SummerCamp.exe is still running.
Related
I have below command and saved it as a .bat file.
taskkill /F /IM explorer.exe
start /realtime chrome.exe
now I want to add some further command so that upon closing google chrome Windows Explorer process gets started automatically.
use start /wait to wait until the started process is finished/exited. Then just execute explorer.exe
taskkill /F /IM explorer.exe
start /realtime /wait chrome.exe
explorer.exe
Note: I don't think, its a good idea to kill explorer or to start a browser as "realtime", but I see your point: being on a meager system you want to assign every available resource to the task to be done.
(But Chrome might not be the best choice in this case)
Try the following with administrator privileges
start /min taskkill.exe /f /im explorer.exe 2>nul >nul && start "" /wait "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" && start "" /wait /realtime "%windir%\explorer.exe" && start "" /realtime "%windir%\system32\taskkill.exe" /f /im cmd.exe <nul
This final part: start "" /realtime "%windir%\system32\taskkill.exe" /f /im cmd.exe <nul, can be replace by call some_bat.bat <nul with all commands that you need to run.
I want write batch script:
Open cmd.exe and then run command which run minimalized Matlab (MATLAB.exe) and then matlab app (MATLABWindow.exe)
After that it must check if Matlab app is working
if yes, do nothing (still checking)
if not, it will kill minimalized MATLAB.exe
What I wrote but didnt work except running matlab and matlab app:
#ECHO OFF
START cmd.exe /min /k "matlab -nosplash -nodesktop -minimize -r "matlab.apputil.run('ThorlabsLC100APP')""
taskkill /F /IM cmd.exe
SLEEP 30
:search
TASKLIST|FIND "MATLABWindow.exe"
IF %ERRORLEVEL% equ 0 (
GOTO search)
ELSE (GOTO found)
TIMEOUT /T 5
GOTO search
:found
taskkill /im MATLAB.exe
EXIT
Thanks
Solved:
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
#ECHO OFF
START /min cmd.exe /k "matlab -nosplash -nodesktop -minimize -r "matlab.apputil.run('ThorlabsLC100APP')""
timeout /t 30 /nobreak
:loop
tasklist /FI "IMAGENAME eq MATLABWindow.exe" | findstr "MATLABWindow.exe" >nul
if %ERRORLEVEL% == 1 goto mycode
goto loop
:mycode
taskkill /F /IM MATLAB.exe
taskkill /F /IM cmd.exe
end
I have a batch file that starts two programs :
#echo off
start "" "C:\Program Files (x86)\Kodi\Kodi.exe"
start "" "C:\Program Files\OpenVPN\bin\openvpn-gui.lnk"
Now when i close program "Kodi", i want that it close automatically first the task "openvpn-gui.exe" and then "openvpn.exe"
Thank you !
What about this:
start "" "C:\Program Files\OpenVPN\bin\openvpn-gui.exe"
start "" "C:\Program Files\OpenVPN\bin\openvpn.exe"
start "" /WAIT "C:\Program Files (x86)\Kodi\Kodi.exe"
taskkill /IM "openvpn.exe"
taskkill /IM "openvpn-gui.exe"
Not tested, but give a try :
#echo off
Title Killing two process automatically after closing one program manually
set "RunningProcess=Kodi.exe"
set "Process2Kill=openvpn-gui.exe openvpn.exe"
tasklist /fi "imagename eq %RunningProcess%" /nh |find /i /c "%RunningProcess%"|findstr "^1$" >nul
If "%Errorlevel%" EQU "1" (
For %%a in (%Process2Kill%) do Call :KillProcess "%%a"
) else (
echo %RunningProcess% is still running
)
pause & exit
:KillProcess
Taskkill /f /im "%~1">nul 2>&1
goto :eof
I need a .bat file that will close and re-open start.cmd (C:\Users\Jake\Desktop\PocketMine-MP\start.cmd) <-- that's the file location. I need it to close and re-open every 75 min. The terminal has to close it can't stay open and launch another all I've gotten so far is:
#echo off
:loop
start "start.cmd" "C:\Users\Jake\Desktop\PocketMine-MP\start.cmd
timeout /t 20
taskkill /f /im "start.cmd" >nul
goto loop
Its starting the terminal every 20 seconds like I want it too but its not closing the old one.
If anyone can help it would assist me and my small network greatly.
Rename start.cmd to bat_start.cmd then try the following.
#echo off
:loop
start "bat_start.cmd" "C:\Users\Jake\Desktop\PocketMine-MP\bat_start.cmd"
timeout /t 20
taskkill /f /fi "windowtitle eq bat_start.cmd*" /im "cmd.exe" >nul
goto loop
If you use same file for control the loop and start file again, then it's fall in recursion. Following example work for me,
#echo off
:loop
start "test2" "C:\test2.bat"
timeout /t 60
taskkill /f /fi "windowtitle eq test2*" /im "cmd.exe" >nul
goto loop
test2 file
#echo off
echo "start job here"
:: Do your work here
pause :: remove the pause, it's just for simulating
exit
You can use the TimeCommander plugin. Set to run a restart command every 75 minutes.
I try to create visual studio post-build event command line and i want:
to kill process if exist;
copy file;
launch a program;
start taskkill /f /im app.exe /t & xcopy /y
"$(TargetPath)" "C:\Program Files (x86)\path\$(TargetFilename)" & start "" "C:\Program Files (x86)\program\app.exe"
I use start taskkill /f /im app.exe /tinstead of taskkill /f /im app.exe /t because if the process not exists i get not found error
Now all tree command runs OK with no error but the last command not launch the program but if i execute this command separately the program is executed.
How can i fix this?
You have a Timing Problem.
Try:
start /wait taskkill /f /im app.exe /t & xcopy /y "D:\Workspaces\Dev\path\bin\Debug\my.dll" "C:\Program Files (x86)\path\my.dll" & start "" "C:\Program Files (x86)\program\app.exe"