Greetings,
In order to learn how to use the AT scheduler from VBS I set myself
the task of creating an alarm clock (more acurately - an alarm). It
seems borderline useful so I give it here. Is there a better way to
have one script turn off another than the way I do it? Going through
text files seems too round-about for me. I've done things along this
line in Excel VBA using DoEvents and public variables and I couldn't
think of anything better than text files to play the role of publc
variables *between* scripts.
On my desktop I have the following two scripts:
Script 1:
'SetAlarm.vbs
Set ws = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
when = InputBox("When do you want to wake up?")
'needs to be in military time! e.g. 14:15 for 2:15 PM
Set f = fso.OpenTextFile("C:\AlarmFlag.txt",2,true)
f.Write "On"
f.close
ws.Run("at " & when & " ""C:\Alarm.vbs""")
__________________________________________
Script 2:
'AlarmOff.vbs
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\AlarmFlag.txt",2,true)
f.Write "Off"
f.close
____________________________________________
Finally, in my C directory I have:
Script 3:
'Alarm.vbs
Set ws = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\AlarmFlag.txt",1,true)
Do
ws.Run "%comspec% /c echo " & Chr(07), 0, True 'beep!
WScript.sleep 1000
Set f = fso.OpenTextFile("C:\AlarmFlag.txt",1,true)
If f.ReadAll = "On" Then
StopNow = False
Else
StopNow = True
End If
f.close
Loop Until StopNow
________________________________
I hope you find the above at least entertaining
-John Coleman