You should write like this :
Do While True
ctime = FormatDateTime(Now(),4)
If ctime = "09:00" Or ctime = "10:00" Or ctime = "11:20" Or ctime = "12:20" Then
msg = Msgbox ("Have you done your register ?",4+32+4096,Now())
If msg = VbNo Then
Msgbox "Please take it immediately.",48+4096,Now()
WScript.Sleep 60000
Else
WScript.Sleep 60000
End If
ElseIf ctime = "14:05" Then
msg = Msgbox ("Have you done your register ?",4+32+4096,Now())
If msg = VbNo Then
Msgbox "Please take it immediately !",48+4096,Now()
Exit Do
WScript.Quit
Else
Exit Do
WScript.Quit
End If
End If
Loop
I add some funny stuff like to be get alarmed by an alarm from the net, just give a try if you like !
Option Explicit
If AppPrevInstance() Then
MsgBox "There is an existing proceeding !" & VbCrLF &_
CommandLineLike(WScript.ScriptName),VbExclamation,"There is an existing proceeding !"
WScript.Quit
Else
Dim ctime,msg,Time1,Time2,Time3,Time4,LastTime2GoAway,Alarm
Time1 = "09:00" : Time2 = "10:00" : Time3 = "11:20" : Time4 = "12:20" : LastTime2GoAway = "14:05"
Alarm = "http://soundbible.com/1080-Airhorn.html"
Do While True
ctime = FormatDateTime(Now(),4)
If ctime = Time1 Or ctime = Time2 Or ctime = Time3 Or ctime = Time4 Then
If CheckConnectionInternet() = True Then
Call Alert(Alarm)
msg = Msgbox ("Have you done your register ?",4+32+4096,Now())
If msg = VbNo Then
Msgbox "Please take it immediately.",48+4096,Now()
Call Pause(60)
Else
Call Pause(60)
End If
Else
msg = Msgbox ("Have you done your register ?",4+32+4096,Now())
If msg = VbNo Then
Msgbox "Please take it immediately.",48+4096,Now()
Call Pause(60)
Else
Call Pause(60)
End If
End If
ElseIf ctime = LastTime2GoAway Then
If CheckConnectionInternet() = True Then
Call Alert(Alarm)
msg = Msgbox ("Have you done your register ?",4+32+4096,Now())
If msg = VbNo Then
Msgbox "Please take it immediately !",48+4096,Now()
Exit Do
WScript.Quit
Else
Exit Do
WScript.Quit
End If
Else
msg = Msgbox ("Have you done your register ?",4+32+4096,Now())
If msg = VbNo Then
Msgbox "Please take it immediately !",48+4096,Now()
Exit Do
WScript.Quit
Else
Exit Do
WScript.Quit
End If
End If
End If
Loop
End If
'**************************************************************************
Sub Alert(WebSite)
Dim objExplorer
Set objExplorer = CreateObject("InternetExplorer.Application")
objExplorer.Navigate WebSite
objExplorer.Visible = 0 'Invisible
Do While (objExplorer.Busy)
Wscript.Sleep 500
Loop
Wscript.Sleep 5000
objExplorer.Quit
End Sub
'**************************************************************************
Function AppPrevInstance()
With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptFullName) & _
" AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")
AppPrevInstance = (.Count > 1)
End With
End With
End Function
'**************************************************************************
Function CommandLineLike(ProcessPath)
ProcessPath = Replace(ProcessPath, "\", "\\")
CommandLineLike = "'%" & ProcessPath & "%'"
End Function
'**************************************************************************
Function CheckConnectionInternet()
Dim strComputer,objPing,objStatus
strComputer = "smtp.gmail.com"
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery _
("select * from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then
CheckConnectionInternet = True
Else
CheckConnectionInternet = False
End If
Next
End Function
'**********************************************************************************************
Sub Pause(NSeconds)
Wscript.Sleep(NSeconds*1000)
End Sub
'**************************************************************************************