DonationCoder.com Software > Finished Programs
DONE: Run At Specified Time
rjbull:
If you can use an old DOS program, take a look at my earlier post: Re: NANY 2011 Pledge: Reliable File Watcher Batcher Robot
sprint907:
hi Ath,
Thanks a lot. That is exactly what I was looking for.
Anyways, I scraped vbscript code from the internet and wrote one myself .
Am posting the code here .. may be it will help someone else
'================================================================================
'start of script
'
'Usage: wait.vbs 16:30
'Sleep till 4.30PM and then exits
Option Explicit
Dim WshShell
Dim strEventInfo
Dim intSeconds, intMicrotime
Set WshShell = CreateObject("WScript.Shell")
'================================================================================
dim inHour
dim inMinute
dim segments
segments = Split(WScript.Arguments.Item(0),":")
inHour = segments(0)
inMinute = segments(1)
inHour = CInt(inHour)
inMinute = CInt(inMinute)
'Wscript.Echo "Hour = " & inHour
'Wscript.Echo "Minute = " & inMinute
'================================================================================
while( (currHour <= inHour) and (currMinute < inMinute))
dim now1
now1=now()
'Wscript.echo now1
segments = Split(now1," ")
dim timeComponent
timeComponent = segments(1)
'Wscript.echo "timeComponent = "+timeComponent
dim currHour, currMinute, currSeconds
segments = Split(timeComponent,":")
currHour = segments(0)
currMinute = segments(1)
currSeconds = segments(2)
'Wscript.echo "currHour = "+currHour
'Wscript.echo "currMinute = "+currMinute
'Wscript.echo "currSeconds = "+currSeconds
currHour = CInt(currHour)
currMinute = CInt(currMinute)
currSeconds = CInt(currSeconds)
'Wscript.echo currHour & ":" & currMinute
WScript.Sleep 1000
wend
'================================================================================
'end of script
sprint907:
Ath,
Is there a way to specify that I need to wait till the next day? I do not want to update the script everytime to give the next day's date in the command.
for example:-
instead of
SleepTill.exe 2012-11-15
or
SleepTill.exe 2012-11-16
I should be able to give
SleepTill.exe NEXTDAY
or something similar.
regards
Ath:
I can add a feature like that. I'm not sure when I'll be working on the dev-system where I've made this tool. Maybe today, maybe tomorrow. Please hang-on.
Ath:
SleepTill updated/reached version 1.0.0
By request I added a few parameters/features:
- Date and Time offsets from 'now' can be specified
- No longer accepts '-' as option-specifier (needed for the days offset)
The offset for days can be specified by using -+<days> instead of a date. (Both the - and the + need to be there!)
Specify the offset for hours or minutes (seconds is no useful option imho) by using :+<hours> or ::+<minutes>
If an hour or minute offset is given, it is calculated from the current time, not from 00:00, that wouldn't be usable.
The updated /? help message:
SleepTill 1.0.0 (c) 2012, Ath : Wait for a date/time to occur, then continue.
Usage:
SleepTill [date] [-+days] [time] [:+hours|::+mins] [/d] [/?]
[date] : Optional date in yyyy-mm-dd format, default: today
[-+days] : Add 'days' to current date to wait for
[time] : Optional time in hh:mm[:ss] format, if not supplied: 00:00
[:+hours|::+mins] : Add 'hours' or 'minutes' to current time
/d : Show some debugging info
/? : Show this helpmessage
Remarks:
- Either date or time, or both, should be provided to start the wait
- Date/time should be in the future to start the wait
- Pressing Ctrl-C stops the wait
Download attached zipfile and extract. Use as documented.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version