How to Stop a Looping WinBatch script
Keywords: stop a looping WinBatch script WinTitle
Question:
I've written a continuous looping script which checks for presence of a lock file, deletes
it, then waits half an hour before
looping. The script is meant to run continuously, but how can I permit an administrator to
stop the script for modifications?
Answer:
In the Main Program Code, when the continuous loop discovers that the window title name
is not the normal window title of "Fruitcake Server", it will exit:
mynormaltitle="Fruitcake Server" ;pick a unique name
WinTitle("",mynormaltitle) ;set winbatch window to unique name
while 1
for xx=1 to 180
if WinName("")!=mynormaltitle then exit ;wait for title to change
TimeDelay(10)
Next
If FileExist("xxx")==1 then FileDelete(xxx)
end while
Then create ShutDown Code for a separate WinBatch script, which changes the normal title
to "Shutdown":
WinTitle("Fruitcake Server","Shutdown")
Article ID: W13266
Filename: Stopping a Looping WinBatch script.txt