LastBootUpTime

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 
Visual Basic Code:
'<!--******************************************************************** '* '* File: LastBoot.vbs '* Author: Frank Wenzel '* Created: 21.08.2007 '* Version: 1.00 '* Modified: 00.00.0000 '* '* Description: Zeigt die Zeit des letzten reboots und die Betriebsdauer an '* '* needed: WMI '* '* '* '********************************************************************--> Option Explicit Dim strComputer Dim objWMI, objErgebnis, objWMIDT Dim objInstance Dim strLocalTime Dim strBoot Dim dtBoot Dim dtLocalTime   strComputer = WScript.Arguments.Item(0) Set objWMI = GetObject("winmgmts:\\" &amp; strComputer) Set objErgebnis = objWMI.InstancesOf("Win32_OperatingSystem") Set objWMIDT = CreateObject("WbemScripting.SWbemdateTime")   For Each objInstance in objErgebnis strLocalTime = objInstance.LocalDateTime strBoot = objInstance.LastBootupTime objWMIDT.value = strBoot dtBoot = objWMIDT.getVarDate objWMIDT.value = strlocalTime dtLocalTime = objWMIDT.getVarDate WScript.Echo "LastBoot: " &amp; FormatDateTime(dtBoot, vbLongDate) &amp; " " &amp; FormatDateTime(dtBoot, vbLongTime) WScript.Echo "Betriebsdauer in Stunden: " &amp; DateDiff("h", dtBoot, dtlocalTime) Next