Reputation: 61
Hey Guy I am running a socket code which is written in python and due to some reasons i need to rerun it after every 5 min some one suggested me to use task scheduler i tried, but it was not running so I searched and found a script which runs the program after every 5 min in .exe format. Now main problem is, it opens a new window and old window is still open. for eg: when I run the program it open in 1 number window. After 5 min it opens 2 number window in which program is running but due to it is socket programming it is connected to 1 number window. Now I want to close 1 number window so that the socket may get connect to 2 number window.
I think it is a shell window and program is in .bat format.
The code is:
:loop
@echo off
start python "python program location"
timeout /t 300 /nobreak
exit0
goto :loop
The line "@echo off" and "exit0" was suggested in some articles but the are not working. "300" is time in sec of 5 min
Upvotes: 0
Views: 428
Reputation:
Give the window a title, then kill it before starting the new one. Here we are giving it a title name of MyScript
and we're also just killing it by that name:
@echo off
:loop
start "MyScript" python "python program location"
timeout /t 300 /nobreak
taskkill /FI "WINDOWTITLE eq MyScript"
goto :loop
Upvotes: 0