我需要一些想法来纠正这个VBS代码

时间:2014-05-26 13:44:57

标签: vbscript


大家好。
希望大家都好。
我需要以下代码的帮助,其中的部分(评论专栏)说"'从这里需要帮助'":

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")
For Each objItem in colItems

MsgBox "Welcome to the ALARM tool",0+0,"ALARM tool"
MsgBox "Note: 1) If the computer is given a shutdown or a restart command then the alarm will be disabled. 2) This ALARM tool dosen't support decimals & words. If you will enter a decimal, the elapsed message box will appear without processing the alarm due to the error. If you enter words then an error message will appear.",0+0,"ALARM tool"
thour=InputBox ("Type which hour you want the alarm to elapse in 24-hour format from 0 to 23 inclusive (not 24; instead 0): (E.G: 19, 15)","ALARM tool")
If thour="" Then
 MsgBox "The value is empty, so no alarm is set.",16,"ALARM tool"
 WScript.Quit
End If

tmin=InputBox ("Type which minute you want the alarm to elapse from 0 to 60 inclusive:","ALARM tool")
If tmin="" Then
 MsgBox "The value is empty, so no alarm is set.",16,"ALARM tool"
 WScript.Quit
End If

c=InputBox ("Enter your comment; leave it blank if you don't want one:","ALARM tool")

If c="" Then
 MsgBox "Time: ''"+thour+":"+tmin+"''       Comment: None",0,"ALARM tool: Preview"
Else
 MsgBox "Time: ''"+thour+":"+tmin+"''       Comment: ''"+c+"''",0,"ALARM tool: Preview"
End If

co=MsgBox ("Are you sure?",36,"ALARM tool")
If co="7" Then
 MsgBox "Alarm cancelled!!!",0,"ALARM tool"
 WScript.Quit
End If

'Help needed from here'

Do
If thour=objItem.Hour Then
 If tmin=objItem.Minute Then
  If c="" Then
   MsgBox "ALARM set to elapse on "+thour+":"+tmin+" has elapsed!!!",0+0,"ALARM set to elapse in "+t
   WScript.Quit
  Else
   MsgBox c,0+0,"ALARM set to elapse in "+t
   WScript.Quit
  End If
 End If
End If

'No more help needed after this'

If Err.Number <> 0 Then
 MsgBox "There's an error while setting the alarm. Maybe you typed words or it's an internal error. Please try again. Sorry for the inconvenience.",0,"ALARM tool"
 WScript.Quit
End If
Loop
Next

你可以给我答案,即使你自己使用它。
主题:特定时间的警报
我要感谢帮助我和它是一个非常好的帮助。

0 个答案:

没有答案