另存为.vbs- 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'")
- For Each objEvent In colLoggedEvents
- Flag = Flag + 1
- If Flag = 1 Then
- SWDT.Value = objEvent.TimeWritten
- Wscript.Echo "本次开机时间: " & SWDT.GetVarDate(True)
- ElseIf Flag = 2 Then
- SWDT.Value = objEvent.TimeWritten
- Wscript.Echo "上次关机时间: " & SWDT.GetVarDate(True)
- ElseIf Flag = 3 Then
- SWDT.Value = objEvent.TimeWritten
- Wscript.Echo "上次开机时间: " & SWDT.GetVarDate(True)
- Exit For
- End If
- Next
复制代码
|