系统时间与txt文件中的时间匹配时显示消息框?

时间:2016-04-15 02:40:46

标签: vbscript

我编写了一个脚本,当系统时间与我希望消息框显示消息的文件中的时间相匹配时,创建一个小时偏移的文本文件

我已经尝试了以下代码,但它不起作用

LicTimeLoc = "J:\Groups\Design\Student Work\UStationTest\LicT.txt"

Set fso = CreateObject("Scripting.FileSystemObject")
set LicTimeCheck = fso.CreateTextFile(LicTimeLoc, True)
LicTimeCheck.WriteLine DateAdd("s",5,Now())
LicTimeCheck.Close

Set LicTimeCheck = fso.OpenTextFile(LicTimeLoc)
NextLic = LicTimeCheck.ReadAll
Do Until Now = NextLic
Loop
msgbox "License now available"

1 个答案:

答案 0 :(得分:0)

我找到了我想要的详细信息here

我编辑它以满足我的需要,现在当系统时间大于比较值时它会显示一条消息

LicTimeLoc = "J:\Groups\Design\Student Work\UStationTest\LicT.txt"

Set fso = CreateObject("Scripting.FileSystemObject")
set LicTimeCheck = fso.CreateTextFile(LicTimeLoc, True)
LicTimeCheck.WriteLine DateAdd("s",5,Time())
LicTimeCheck.Close

Set LicTimeCheck = fso.OpenTextFile(LicTimeLoc)
NextLic = LicTimeCheck.ReadAll

comparetime = TimeValue(NextLic)

Do until comparetime < systime
systime = time
Wscript.Sleep(1000)
loop
msgbox "License now available"