Alternative to Scheduled Tasks?
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Alternative to Scheduled Tasks?
Hello,
Admin, please move if you feel appropriate....
For security reasons (???), our company has disabled scheduled tasks within windows XP, so I am looking for an alternative. What I would like to do is run a BATch file at 07:45am daily, scheduled tasks seemed the obvious route, but this is not currently an option.
Is there a BATch or VBS or a.n.other alternative to schedule a BATch execution daily?
Admin, please move if you feel appropriate....
For security reasons (???), our company has disabled scheduled tasks within windows XP, so I am looking for an alternative. What I would like to do is run a BATch file at 07:45am daily, scheduled tasks seemed the obvious route, but this is not currently an option.
Is there a BATch or VBS or a.n.other alternative to schedule a BATch execution daily?
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Alternative to Scheduled Tasks?
You could use an Excel workbook that remains open all the time.
In a standard module:
and in the ThisWorkbook module (to start the whole thing when the workbook is opened):
In a standard module:
Code: Select all
Public dtmRun As Date
Sub MyMacro()
Shell "C:\Test\Something.bat"
dtmRun = TimeSerial(7, 45, 0)
Application.OnTime dtmRun, "MyMacro"
End Sub
Code: Select all
Private Sub Workbook_Open()
dtmRun = TimeSerial(7, 45, 0)
Application.OnTime dtmRun, "MyMacro"
End Sub
Last edited by HansV on 07 Feb 2011, 20:29, edited 1 time in total.
Reason: to correct omission
Reason: to correct omission
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
Hans, I tried this out, changing the time to 20:10 in both macro's and I get the following error:
".Ontime" is highlighted.
".Ontime" is highlighted.
You do not have the required permissions to view the files attached to this post.
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 12604
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Alternative to Scheduled Tasks?
You have not included the name of the macro in the Application.OnTime line
Change
Application.Ontime dtmRun
to
Application.Ontime dtmRun MyMacro
Change
Application.Ontime dtmRun
to
Application.Ontime dtmRun MyMacro
StuartR
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Alternative to Scheduled Tasks?
Stuart is correct - I changed the name of the macro, started to modify the code then got distracted. I have edited my previous reply.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
OK, Thanks. Whilst I was waiting on a reply, I commented out lines 2&3 of "MyMacro" and the process appears to work without them. Why is this? I cannot get my head around the need for the 2 lines if the workbook open event fires the shell at the specified time?
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 12604
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Alternative to Scheduled Tasks?
These two lines reschedule the task to run again the next day
StuartR
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
Aha, makes perfect sense! Thanks Stuart & Hans.
Nathan
There's no place like home.....
There's no place like home.....
-
- 5StarLounger
- Posts: 1120
- Joined: 26 Jan 2010, 11:32
- Location: "What a mighty long bridge to such a mighty little old town"
Re: Alternative to Scheduled Tasks?
You didn't say if IT had disabled installing software. If not try this. I use it for a number of repeating tasks at work.
John
“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube
“Always trust a microbiologist because they have the best chance of predicting when the world will end”
― Teddie O. Rahube
-
- PlatinumLounger
- Posts: 5408
- Joined: 24 Jan 2010, 08:33
- Location: A cathedral city in England
Re: Alternative to Scheduled Tasks?
Another way could be to start a calling BATch file, and within it check the time every minute to see if it's 07:45 yet.
If it is, CALL the 'real' BATch file and return to the caller, which should wait for (say) 23 hours-worth of seconds (to some time tomorrow well before 07:45).
If it isn't, wait another 50 seconds (say), and loop round to try again.
Waits can be implemented using PING in the form PING -n 999 127.0.0.1 > nul
My figure 999 means that it will PING every second for 998 seconds (n-1), so waiting 50 seconds would be coded as PING -n 51 127.0.0.1 > nul
Other WAIT mechanisms are available, but this one is effectively 'built-in'.
LATER... I remind myself that some geeky computer magazine produced a T-shirt bearing the text:
There's no place like 127.0.0.1
For IPv6, this will have to be updated to:
There's no place like ::1
(or 0:0:0:0:0:0:0:1)
If it is, CALL the 'real' BATch file and return to the caller, which should wait for (say) 23 hours-worth of seconds (to some time tomorrow well before 07:45).
If it isn't, wait another 50 seconds (say), and loop round to try again.
Waits can be implemented using PING in the form PING -n 999 127.0.0.1 > nul
My figure 999 means that it will PING every second for 998 seconds (n-1), so waiting 50 seconds would be coded as PING -n 51 127.0.0.1 > nul
Other WAIT mechanisms are available, but this one is effectively 'built-in'.
LATER... I remind myself that some geeky computer magazine produced a T-shirt bearing the text:
There's no place like 127.0.0.1
For IPv6, this will have to be updated to:
There's no place like ::1
(or 0:0:0:0:0:0:0:1)
John Gray
"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...
"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
Thankyou very much Jon, this is well worth consideration for another task I have in mind.jonwallace wrote:You didn't say if IT had disabled installing software. If not try this. I use it for a number of repeating tasks at work.
Nathan
There's no place like home.....
There's no place like home.....
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
Hi John,John Gray wrote:Another way could be to start a calling BATch file, and within it check the time every minute to see if it's 07:45 yet.
If it is, CALL the 'real' BATch file and return to the caller, which should wait for (say) 23 hours-worth of seconds (to some time tomorrow well before 07:45).
If it isn't, wait another 50 seconds (say), and loop round to try again.
Waits can be implemented using PING in the form PING -n 999 127.0.0.1 > nul
My figure 999 means that it will PING every second for 998 seconds (n-1), so waiting 50 seconds would be coded as PING -n 51 127.0.0.1 > nul
Other WAIT mechanisms are available, but this one is effectively 'built-in'.
LATER... I remind myself that some geeky computer magazine produced a T-shirt bearing the text:
There's no place like 127.0.0.1
For IPv6, this will have to be updated to:
There's no place like ::1
(or 0:0:0:0:0:0:0:1)
Thankyou for your response. For now, I am hoping that Hans solution above will suit my current needs, however a BATch alternative is still of interest for future reference. Would you mind providing a small demonstration of how 'waits' could be used to call another BAT on a specified date & time? TIA!
Nathan
There's no place like home.....
There's no place like home.....
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
Code: Select all
Private Sub Workbook_Open()
dtmRun = TimeSerial(7, 45, 0)
Application.OnTime dtmRun, "Bat_Schedule"
End Sub
Nathan
There's no place like home.....
There's no place like home.....
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Alternative to Scheduled Tasks?
Could this occur because the workbook has been opened twice? If so, you could try this:
Code: Select all
Private Sub Workbook_Open()
dtmRun = TimeSerial(7, 45, 0)
On Error Resume Next
' Kill scheduled run if present
Application.OnTime dtmRun, "Bat_Schedule", , False
' Schedule run
On Error GoTo 0
Application.OnTime dtmRun, "Bat_Schedule"
End Sub
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 1185
- Joined: 24 Jan 2010, 12:02
- Location: Wales, UK.
Re: Alternative to Scheduled Tasks?
I have no idea what causes the occasional duplicate. Thanks for the solution!HansV wrote:Could this occur because the workbook has been opened twice? ....
Nathan
There's no place like home.....
There's no place like home.....