Core code:
StrComputer = "." Set objWMIService = GetObject ("winmgmts:" _ & "{impersonationlevel=impersonate}!\\" _ & StrComputer & "\root\") Cimv2 ") Set colloggedevents = objWMIService.ExecQuery _ (" SELECT * from Win32_NTLogEvent "_ &" Where Logfile = ' Syste M ' and EventCode = ' 6005 ' Or eventcode = ' 6006 ') for each objevent in colloggedevents Flag = Flag + 1 If Flag = 1 The N WScript.Echo "This Boot Time:" & Formatwmiutc (objevent.timewritten) ElseIf Flag = 2 Then wscript.echo "Last Shutdown Time:" & FORMATWMIUTC (objevent.timewritten) ElseIf Flag = 3 Then wscript.echo "Last Boot Time:" & FORMATWMIUTC (Objevent.ti Mewritten) Exit for end If Next ' FORMATUTC Function formatwmiutc (wmidatestring) DS = "//::" FORMATWMIUTC = L EFT (wmidatestring,2) for i = 2 to 7 FORMATWMIUTC = FORMATWMIUTC & Mid (wmidatestring, I * 2-1, 2) & Mid (DS, i,1) Next ' FORMATWMIUTC = Mid (wmidatestring, 1, 4) & "Year" _ ' & Mid (Wmidatestring, 5, 2) & "Month" _ "& Mid (Wmidatestring, 7, 2) & "Day" _ ' & Mid (wmidatestring, 9, 2) & ":" _ ' & Mid "(Wmidat Estring, 2) & ": _ ' & Mid (wmidatestring,13, 2) End Function
Save the above code as a file for the VBS suffix, and double-click to run it. See the boot time, the last time the switch machine.