Macro Scheduler not repeating schedule

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

parsa033
Newbie
Posts: 4
Joined: Thu Aug 16, 2007 4:03 am

Macro Scheduler not repeating schedule

Post by parsa033 » Mon Nov 11, 2013 9:04 am

When I run the code manually it works perfectly. There are no errors or issues. I was only able to get Macro scheduler to repeat it once every 10 minutes one time and it only went on for an hour.

It only works once I run it manually and the scheduler doesn't work. I'm not sure what the deal with it is...

I have "Run When" selected the following:
M-S ALL CHECKED
Time: 00:00:00 run every 10 minutes
Advance option: run immediately.

here's the code also:
VBSTART
Dim IE

Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub

Sub Navigate(URL)
IE.Navigate URL
End Sub

Sub WaitBusy
do while IE.Busy
loop
End Sub

Sub KillIE
IE.Quit
Set IE = nothing
End Sub

VBEND



HTTPRequest>http://www.Url.com?setnotice=1,,GET,,strHTML,,,, //Set up some VBS functions for use later

//Tweet from Macro Scheduler
Let>url=http://www.Url.com?search=Submit
Let>message=Hit URL
HTTPRequest>url,,GET,,response,,

//Output results
//MessageModal>response

Position>accounts.com,response,1,dPos,
if>dPos>1
wait>0.2
Let>String1=Login
Length>String1,String1_length

Position>String1,response,1,StartAt
Add>StartAt,String1_length
Position>String2,response,StartAt,EndAt,FALSE
Let>myLen=EndAt-StartAt

MidSTr>response,StartAt,myLen,myWeather
Let>Dialog1.msMemo1=%myWeather%
//Output results
//MessageModal>myWeather

//Perform the HTTP request
// Let>HTTP_TIMEOUT=10
// Let>HTTP_SSL=1

//Do the business .....

VBRun>CreateIE

//Focus the new IE window
VBEval>IE.Hwnd,ie_handle
Let>WIN_USEHANDLE=1
SetFocus>ie_handle
Let>WIN_USEHANDLE=0

VBRun>Navigate,myWeather

//VBRun>ClickLink,Accept
wait>2
IfWindowOpen>Sign in - Accounts - Windows Internet Explorer
ResizeWindow>Sign in - Accounts - Windows Internet Explorer,500,500
MoveWindow>Sign in - Accounts - Windows Internet Explorer,0,0
wait>1
MouseMove>175,263
LClick
Send Character/Text>%email%
wait>1
Press Tab
Send Character/Text>%Pass%
Press Enter
wait>1
MouseMove>361,333
wait>2
LClick
LClick
MouseMove>348,335
LClick
LClick
wait>5
IfWindowOpen>GP - Windows Internet Explorer
CloseWindow>GP - Windows Internet Explorer
Endif

Else
ResizeWindow>RPermission - Windows Internet Explorer,500,500
MoveWindow>RPermission - Windows Internet Explorer,0,0

wait>2
MouseMove>361,333
wait>1
LClick
LClick
MouseMove>348,335
wait>1
LClick
LClick
wait>5
IfWindowOpen>RPermission - Windows Internet Explorer
CloseWindow>RPermission - Windows Internet Explorer
Endif
Endif

Else
Exit>0
EndIf

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Nov 11, 2013 2:21 pm

Time: 00:00:00 run every 10 minutes
So it is set to start for the first time at midnight and then every 10 minutes thereafter.

Have you waited until midnight? Or set the start time to a nearer time (e.g. 2 minutes time or the next 10 minutes slot. E.g.2. If the time now is 9.27 set it to 9.30. It will then run at 9.30 and every 10 mins thereafter.)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

parsa033
Newbie
Posts: 4
Joined: Thu Aug 16, 2007 4:03 am

Post by parsa033 » Mon Nov 11, 2013 6:21 pm

Marcus Tettmar wrote:
Time: 00:00:00 run every 10 minutes
So it is set to start for the first time at midnight and then every 10 minutes thereafter.

Have you waited until midnight? Or set the start time to a nearer time (e.g. 2 minutes time or the next 10 minutes slot. E.g.2. If the time now is 9.27 set it to 9.30. It will then run at 9.30 and every 10 mins thereafter.)

Yes, it runs once then doesn't run again...

If i keep doing it, i might get lucky and get it to run 2-3 times, them stops competently. Macro Scheduler is fully running but the macro is not running. I also have logs setup...

I have Version 14.0.17 Standard Paid license.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Nov 18, 2013 4:07 pm

- Does the script finish, or is it left running?
- Once it finishes you should see the schedule time advance by the interval required.
- Are you leaving the machine unlocked?
- Is the machine left logged in?
- If using terminal server/remote desktop are you making sure you are not disconnecting or minimizing the client?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Fri Jan 16, 2015 7:28 am

was there ever a resolution to this problem? i've been having this problem for the last couple of months now and it's quite annoying. especially since things had been fine for a year or two.

i have my script set to run every 10 min from noon until 6pm. sometimes the script takes longer than 10 min to run; in these cases usually it will not run every 10 min, and instead the next time is set once the script is finished (which is fine). i leave the machine locked, the the script will auto-unlock to run.

recently however (once a day, every few days), the script seems to finish, then the scheduler gets screwed up for this script. the next scheduled time is not set and the machine remains unlocked. other scripts remain unaffected and it's only this one that stops working. i will have to go into the scripts schedule settings and manually set it to the next time. then after 6pm i have to go in again to reset it to noon because it'll reset to sometime around when i manually changed it.

other notes:
- the script hasn't been changed since before and after this started since all it is doing is calling an Excel workbook
- actually as i type this the script has just died twice in one day, first time that's happened

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Macro Scheduler not repeating schedule

Post by Marcus Tettmar » Mon Jan 19, 2015 4:13 pm

Do you have logging enabled for this script so we can try and understand what it is doing and when?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Mon Jan 19, 2015 4:31 pm

i do but i'll need to check if it gets wiped out every run or not. if it does i'll set it to save all and wait til it crashes again before reporting back, thanks

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Mon Feb 02, 2015 1:39 am

Well I seem to have possibly fixed the issue, but I'm not certain. I changed:

Code: Select all

SRT>PrintReports
    Let>RP_WAIT=1
    WriteLn>%logfile%,result,  Printing reports
    RunProgram>C:\Folder\EXCEL.EXE "H:\Folder\MyExcelFile.xlsm"
    Let>RP_WAIT=0
END>PrintReports
...to:

Code: Select all

SRT>PrintReports
    Let>RP_WAIT=1
    WriteLn>%logfile%,result,  Printing reports
    RunProgram>C:\Folder\EXCEL.EXE "H:\Folder\MyExcelFile.xlsm"
    //Let>RP_WAIT=0  <-- Only this line was changed
END>PrintReports
...and haven't had any macro-specific schedule stops since. Computer still freezes on occasion but I think that may be an Excel issue.

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Mon Feb 02, 2015 9:31 am

Alright well as soon as I post...error appears the same day. Maybe I shouldn't have replied! Log doesn't really tell anything; it looks like it calls Excel and never finishes the step:
2015/2/2 17:05:01:208 - 358: // Main entry point
2015/2/2 17:05:01:208 - 360: GoSub>PrintReports
2015/2/2 17:05:01:208 - 375: Let>RP_WAIT=1
2015/2/2 17:05:01:208 - 376: WriteLn>H:\xxxxxxxx\Automation\xxxxxxx\logs\db_reports_ms.log,result, Printing reports
This is the end of the log; I've left off the beginning since it doesn't appear to be relevant.

There was an error dialog that said "Program tried to close application in an unexpected way" or something similar. I'm guessing it's an Excel or Adobe error. How do I prevent Macro Scheduler's repeating schedule to not stop when this happens? There is no instance of Excel in Task Manager. Desktop is unlocked and the listed scheduled time of this script is the last time it ran (meaning it won't run again unless I intervene).

Any ideas?

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Tue Feb 03, 2015 7:26 am

Ugh, happened again today. Excel workbook macro actually completely finishes. Unfortunately I forgot to look at the Macro Scheduler script so I wasn't able to tell if it dies before completion of the the Excel step or after. Repeating schedule for this macro stops working and desktop remains unlocked.

Will remember to check logs next time. In the meantime is there anything I can check besides the MS logs?

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Wed Feb 11, 2015 7:04 am

Okay scheduler died again. So as mentioned before basically this script just calls an Excel workbook (which runs a macro), sends out a log when the workbook is done, then is finished. At this point the next schedule should be set and the screen locked. However, the next schedule is not set and the screen is not locked.

The schedule is set to run every 10 min. from noon til 6pm. (12:05, 12:15, 12:25, etc). The last time it ran was 14:15p, and this is the time that remains in the scheduler.

I checked my Excel workbook log, and it looks like it completed successfully (at 14:26):

Code: Select all

"-------------------------------------"
"Starting: 2015/2/11 下午 02:15:02"
"  Processing source data files..."
<SNIP>
"  "
"  Run Successfully!, 2015/2/11 下午 02:26:51"
Looks like Macro Scheduler never realizes that Excel is finished:

Code: Select all

2015/2/11 14:15:00:958 - Started Macro : <name here>
<SNIP>
2015/2/11 14:15:01:953 - 252: SRT>Notification
2015/2/11 14:15:01:953 - 256: 
2015/2/11 14:15:01:953 - 257: //
2015/2/11 14:15:01:963 - 265: SRT>ErrorHandler
2015/2/11 14:15:01:963 - 269: 
2015/2/11 14:15:01:963 - 270: // GoSub>SendNotification,IsError,Message
2015/2/11 14:15:01:963 - 271: SRT>SendNotification
2015/2/11 14:15:01:963 - 347: Let>script_name=<name here>
2015/2/11 14:15:01:973 - 348: Let>logfile=H:\path\log.log
2015/2/11 14:15:01:973 - 349: Let>notif_to=<an email>
2015/2/11 14:15:01:973 - 350: Let>err_to=<an email>
2015/2/11 14:15:01:973 - 351: Let>ONERROR=ErrorHandler
2015/2/11 14:15:01:973 - 352: 
2015/2/11 14:15:01:983 - 353: // Run Excel portion of report
2015/2/11 14:15:01:983 - 354: GetDate>date
2015/2/11 14:15:01:983 - 355: WriteLn>H:\path\log.log,result,-------------------------------------------------------
2015/2/11 14:15:01:993 - 356: DateStamp>H:\path\log.log,Starting macro
2015/2/11 14:15:01:993 - 357: 
2015/2/11 14:15:01:993 - 358: // Main entry point
2015/2/11 14:15:01:993 - 360: GoSub>PrintReports
2015/2/11 14:15:01:993 - 375: Let>RP_WAIT=1
2015/2/11 14:15:02:003 - 376: WriteLn>H:\path\log.log,result,  Printing reports
What it's supposed to do:

Code: Select all

SRT>PrintReports
    Let>RP_WAIT=1
    WriteLn>%logfile%,result,  Printing reports
    RunProgram>C:\Program Files\MICROSOFT OFFICE\Office14\EXCEL.EXE "H:\path\workbook.xlsm"
    //Let>RP_WAIT=0
END>PrintReports
------
While writing this I noticed something. I also have a batch file (downloads files) that runs minimized every 10 min (12:00, 12:10, etc) for the same time period. This process can sometimes take 20-30+ minutes to finish. Just now, after it finished, the screen locked. And the time for the printing script (the one with the problem) increased by 10 min. It seems like the printing script gets confused with the batch download script and doesn't "finish" until the batch finishes. Any ideas?? This seems to happen sporadically now, once every few days.

Here is the order of downloading/printing from a separate log I use:

Code: Select all

-------------------------------------------------------
2015-02-11:13:55:01:309 - Starting macro
  Printing reports
-------------------------------------------------------
2015-02-11:14:15:01:983 - Starting macro
  Printing reports
-------------------------------------------------------
2015-02-11:14:20:01:005 - Starting macro
  Downloading reports
-------------------------------------------------------
2015-02-11:15:00:01:201 - Starting macro
  Downloading reports
So...
- 2:15: print starts
- 2:20: d/l starts
- 2:26: print finishes (excel does but macro scheduler macro doesn't completely finish. screen should lock here because the download runs w/o unlocking the screen)
- 2:50+: download finishes, screen gets locked and next scheduled times are updated

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Macro Scheduler not repeating schedule

Post by Marcus Tettmar » Wed Feb 11, 2015 2:05 pm

I think it might be that the download script is still running.

Either that or Excel hasn't actually closed. Is there a stray Excel process left running?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Wed Feb 11, 2015 3:33 pm

I checked last time for an Excel instance and didnt see one in task manager. It sounds like it could possibly be the download script, but this situation where it is still running happens multiple times a day every day but the print script normally completes as planned.

kh_kevin
Junior Coder
Posts: 34
Joined: Mon Nov 12, 2012 8:30 am

Re: Macro Scheduler not repeating schedule

Post by kh_kevin » Thu Feb 12, 2015 10:07 am

Happened again earlier -- no rogue Excel.exe instance and everything was fine after the download script finished. I think the print script should not be getting "stuck" on the download script's process. Is this something that can be fixed? Thanks!

Possible issues:
- Scheduler issue with two scripts running at the same time
- Both download and print scripts share two .scp header files (one for constants, one for notifications/logging)...maybe this causes a hang-up?

Can't really think of anything else. One is a self-contained .bat file, the other is a self-contained Excel macro workbook. Both scripts just call the one file then end when finished.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Macro Scheduler not repeating schedule

Post by Marcus Tettmar » Thu Feb 12, 2015 11:30 am

I'm running some tests with some concurrent repeating schedules today.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts