I am new to programming and I want to make a python tool to automate a process. I want to end a running batch file without killing it, is this even possible? I don't want to kill it, because it scans for IP packages in running time and when stopped, creates a file with the data, and I want to work with this file. Thanks for your help
CodePudding user response:
subprocess.call("taskkill /F /im process.exe")
CodePudding user response:
In your batch file, at an appropriate point, try
if not exist stop.txt goto continue
del stop.txt
:wait
timeout /t 1 >nul
if not exist start.txt goto wait
del start.txt
:continue
Use python to create stop.txt
. Wait until stop.txt
is deleted and read your log file. Then create start.txt
to restart.
I'm assuming that your log file is actually closed - that us your logging is
echo .... >>logfile
not
(
command-sequence
)>logfile
where the logfile is not closed until the command-sequence block is terminated.