我需要一个从txt文件(计算机列表)中读取的脚本,并返回在夏令时开始之前我们有多少时间。
到目前为止,这是我的脚本:
strComputer = "C:\temp\computerlist.txt"
For Each computer in strComputer
For Each objItem in colItems
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
dtmTime = CDate(strTime)
Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
Next
Next
DayLightSavingTimes=CDate("21/10/2013 00:00:00")
wscript.echo("It is " & DateDiff("m", Now(), DayLightSavingTimes) & " Months to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("d", Now(), DayLightSavingTimes) & " days to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("h", Now(), DayLightSavingTimes) & " hours to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("n", Now(), DayLightSavingTimes) & " Minutes to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("s", Now(), DayLightSavingTimes) & " seconds to the DayLightSavingTimes!")
当我为一台计算机运行它时,它可以工作:
strComputer = "MyComputer"
WScript.Echo "Running Against Remote Computer Named: " & strComputer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
For Each objItem in colItems
strTime = objItem.Hour & ":" & objItem.Minute & ":" & objItem.Second
dtmTime = CDate(strTime)
Wscript.Echo FormatDateTime(dtmTime, vbFormatLongTime)
Next
DayLightSavingTimes=CDate("21/10/2013 00:00:00")
wscript.echo("It is " & DateDiff("m", Now(), DayLightSavingTimes) & " Months to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("d", Now(), DayLightSavingTimes) & " days to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("h", Now(), DayLightSavingTimes) & " hours to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("n", Now(), DayLightSavingTimes) & " Minutes to the DayLightSavingTimes!")
wscript.echo("It is " & DateDiff("s", Now(), DayLightSavingTimes) & " seconds to the DayLightSavingTimes!")
我得到了预期的结果:
Running Against Remote Computer Named: MyComputer
14:28:22
It is 0 Months to the DayLightSavingTimes!
It is 3 days to the DayLightSavingTimes!
It is 58 hours to the DayLightSavingTimes!
It is 3452 Minutes to the DayLightSavingTimes!
It is 207098 seconds to the DayLightSavingTimes!
我需要在远程计算机上运行相同的结果,存储在computerlist.txt上 我远程运行它的错误是 Microsoft VBScript运行时错误:对象不是集合。
任何提示?
由于