Hi,
I am fairly new to Macro Scheduler and real impressed at its functionality. However I am faced with one issue though. I am accessing some websites and pulling data from it. Sometimes, the file is not available or the site changes but my script is still running and excepting something (a wait window et al). I think this messes up my other jobs when they run (or do they). Is there a way before job#2 runs to check and see if job#1 (or any other schedule job is running) to terminate them so job#2 can run cleanly?
Thanks!
--csim
Terminating a scheduled job
Moderators: JRL, Dorian (MJT support)
One method I use is have each macro Write to a common file near the start. Before that, however, each macro tests for the existence of the common file and will not start until the file does not exist. Then after the macro completes the last line will delete the common file allowing the next macro to proceed. Something like:
If the first script is locked up waiting for a window that will never open perhaps you need to include a wait window timeout see help for WaitWindowOpen>.
Code: Select all
Label>CheckAtStart
IfFileExists>%Temp_Dir%Common_File.tmp
Wait>5
Goto>CheckAtStart
endIf
WriteLn>%Temp_Dir%Common_File.tmp,wres,
//Rest of the Macro
DeleteFile>%Temp_Dir%Common_File.tmp
Hi JRL,
Thanks for the suggestion. I do have timeouts in my WaitWindowOpen. I think I may need more extensive error trapping. The issue is, if the website changes without my knowledge, it makes it difficult to predict what will happen. This is not a dependency issue (wait for one job to finish before starting another). I would like to abort any pending job (maybe the website is down or have changed or script went south) before the next one starts.
Thanks!
Thanks for the suggestion. I do have timeouts in my WaitWindowOpen. I think I may need more extensive error trapping. The issue is, if the website changes without my knowledge, it makes it difficult to predict what will happen. This is not a dependency issue (wait for one job to finish before starting another). I would like to abort any pending job (maybe the website is down or have changed or script went south) before the next one starts.
Thanks!

You could create job#1.5 as below. Schedule job#1.5 to run a minute or two before job#2. The script below will close all instances of msched.exe then restart msched.exe. Once Macro Scheduler is restarted the next scheduled job (job#2) should start on its own with no other jobs running. The script will leave a DOS window behind. This could probably be avoided by writing a VBScript version of taskkill msched.exe, writing it to a .VBS file and executing it. Or you could have job#2 close the DOS window.
Code: Select all
IfFileExists>%TEMP_DIR%killmsched.bat
DeleteFile>%TEMP_DIR%killmsched.bat
EndIf
WriteLn>%TEMP_DIR%killmsched.bat,wresult,taskkill /f /im msched.exe
WriteLn>%TEMP_DIR%killmsched.bat,wresult,%COMMAND_LINE%
Let>RP_WAIT=0
Run>cmd /c %TEMP_DIR%killmsched.bat
Hi JRL,
Good idea! Instead of attempting to kill a pending job (or two), killing the app would take care of that, but how do I restart msched?
Oops - I think I just stumbled upon a solution in this entire thought process but will need to test it out. How about job 1.5 actually identifying msched application and sending the stop combo key strokes to it (stops any job if running). Not sure what would happen to job 1.5 itself right after it sends the keystrokes.
Thanks,
--csim
Good idea! Instead of attempting to kill a pending job (or two), killing the app would take care of that, but how do I restart msched?
Oops - I think I just stumbled upon a solution in this entire thought process but will need to test it out. How about job 1.5 actually identifying msched application and sending the stop combo key strokes to it (stops any job if running). Not sure what would happen to job 1.5 itself right after it sends the keystrokes.
Thanks,
--csim
csim wrote:nstead of attempting to kill a pending job (or two), killing the app would take care of that, but how do I restart msched?
The batch file created in the previously posted script will close all instances of msched.exe and then open one instance that will not include any running scripts.Dick wrote:The script below will close all instances of msched.exe then restart msched.exe.
Sending Shift + Esc keystrokes in a script stops the sending script and that's all. It will not stop other scripts. Run the following and you will never see the message "Did the script get here?"csim wrote:Oops - I think I just stumbled upon a solution in this entire thought process but will need to test it out. How about job 1.5 actually identifying msched application and sending the stop combo key strokes to it (stops any job if running). Not sure what would happen to job 1.5 itself right after it sends the keystrokes.
Code: Select all
Press Shift
Press esc
Release shift
MDL>Did the script get here?