Set SWDT = CreateObject("WbemScripting.SWbemDateTime")
Set WMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colLoggedEvents = WMI.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = 'System' And EventCode = '6005' Or EventCode = '6006'")
set fso=createobject("scripting.filesystemobject")
set fw=fso.createtextfile("a.txt",2)
For Each objEvent In colLoggedEvents
Flag = Flag + 1
If Flag = 1 Then
SWDT.Value = objEvent.TimeWritten
Wscript.Echo "本次开机时间: " & SWDT.GetVarDate(True)
fw.writeline("本次开机时间:"&SWDT.GetVarDate(True))
ElseIf Flag = 2 Then
SWDT.Value = objEvent.TimeWritten
Wscript.Echo "上次关机时间: " & SWDT.GetVarDate(True)
fw.writeline("上次关机时间:"&SWDT.GetVarDate(True))
ElseIf Flag = 3 Then
SWDT.Value = objEvent.TimeWritten
Wscript.Echo "上次开机时间: " & SWDT.GetVarDate(True)
fw.writeline("上次开机时间:"&SWDT.GetVarDate(True))
Exit For
End If
Next
——————————————
true 不是ture,就是这里错了 。
代码是你自己写的么,你能帮我解释解释么!
为什么我机器上面运行colLoggedEvents.count只能是18,是机器上面自动保存的只有18次吗?