Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vbscript 我需要一些想法来纠正这个VBS代码_Vbscript - Fatal编程技术网

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

Vbscript 我需要一些想法来纠正这个VBS代码,vbscript,Vbscript,大家好。 希望大家都好。 我需要以下代码的帮助,部分(注释行)说“需要从这里获得帮助”: strComputer=“” 设置objWMIService=GetObject(“winmgmts:_ &“{impersonationLevel=impersonate}!\\”&strComputer&“\root\cimv2”) Set colItems=objWMIService.ExecQuery(“从Win32\u LocalTime中选择*) 对于每个对象,在colitem中 MsgBox


大家好。
希望大家都好。
我需要以下代码的帮助,部分(注释行)说“需要从这里获得帮助”:

strComputer=“”
设置objWMIService=GetObject(“winmgmts:_
&“{impersonationLevel=impersonate}!\\”&strComputer&“\root\cimv2”)
Set colItems=objWMIService.ExecQuery(“从Win32\u LocalTime中选择*)
对于每个对象,在colitem中
MsgBox“欢迎使用报警工具”,0+0,“报警工具”
MsgBox“注意:1)如果向计算机发出关机或重新启动命令,则报警将被禁用。2)此报警工具不支持小数和文字。如果输入小数,则会出现“已过”消息框,而不会处理错误导致的报警。如果输入文字,则会显示错误消息。“,0+0,“报警工具”
thour=InputBox(“键入您希望警报以24小时格式从0到23(包括24小时)经过的时间(不是24小时,而是0):(例如:19、15)”,“警报工具”)
如果thour=“那么
MsgBox“该值为空,因此未设置报警。”,16,“报警工具”
WScript.Quit
如果结束
tmin=InputBox(“键入您希望警报从0到60(含0到60)的分钟:”,“警报工具”)
如果tmin=”“,则
MsgBox“该值为空,因此未设置报警。”,16,“报警工具”
WScript.Quit
如果结束
c=InputBox(“输入您的注释;如果不需要注释,请留空:”,“报警工具”)
如果c=”“,则
MsgBox“时间:”“+thour+”:“+tmin+”“”注释:无”,0,“报警工具:预览”
其他的
MsgBox“时间:”“+thour+”:“+tmin+”“”注释:”“+c+””,0,“报警工具:预览”
如果结束
co=MsgBox(“你确定吗?”,36,“报警工具”)
如果co=“7”,则
MsgBox“报警已取消!!!”,0,“报警工具”
WScript.Quit
如果结束
“这里需要帮助”
做
如果thour=objItem.Hour,则
如果tmin=objItem.Minute,则
如果c=”“,则
MsgBox“报警设置为在“+thour+”上消失:“+tmin+”已消失!!!”,0+0,“报警设置为在“+t”上消失”
WScript.Quit
其他的
MsgBox c,0+0,“报警设置为在”+t中消失
WScript.Quit
如果结束
如果结束
如果结束
“这之后不需要更多的帮助”
如果错误号为0,则
MsgBox“设置报警时出错。可能是您键入的文字或内部错误。请重试。对于给您带来的不便,深表歉意。”,0,“报警工具”
WScript.Quit
如果结束
环
下一个

您可以给我答案,甚至自己使用。
主题:特定时间的警报
我会感谢您的帮助,这将是一个非常好的帮助。

这里到底有什么问题?如果您希望脚本在某个时间显示消息框,它需要一直运行,直到时间到来。你需要让你的脚本保持活力。使用
WScript.Sleep
睡眠直到触发警报,或在循环中使用
WScript.Sleep
经常检查时间。就我个人而言,我会让我的脚本在TaskScheduler中安排一个新任务。那么你就不需要再去记录时间了。让Windows来做吧。问:你们不明白@Bond我有另一个名为“Alarm tool(v3.0).vbs”的带有
wscript.sleep
命令的文件,但这是“特定时间的报警工具”。你说它可以安排任务吗?请告诉我代码。整个问题都会解决的。如果我们不理解,那是因为你没有说清楚。:)您可以使用
SCHTASKS
命令安排任务在特定时间运行。有关更多信息,请参阅。大家好!我是。。。那时的孩子(现在也是)。现在我明白了@Bond在说什么了。再次感谢!
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