Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Last Boot User Logon Login Explorer Start Time
; Name: BootTimeWMI.wbt ; Purpose: Retrieve last boot time, user logon time, and Explorer start time from WMI ; Author: Les Ferch ; 2008-10-28: Initial release oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") #DefineFunction FormatDate(Date) Y = StrSub(Date,1,4) M = StrSub(Date,5,2) D = StrSub(Date,7,2) H = StrSub(Date,9,2) I = StrSub(Date,11,2) S = StrSub(Date,13,2) Return StrCat(Y,":",M,":",D,":",H,":",I,":",S) #EndFunction ; Last Boot Time oItems = oWMI.ExecQuery("Select * from Win32_OperatingSystem") ForEach oItem In oItems LastBootTime = StrSub(oItem.LastBootUpTime,1,14) Next LastBootTime = FormatDate(LastBootTime) ; User Logon Time oItems = oWMI.ExecQuery("SELECT * FROM Win32_LogonSession") ForEach oItem In oItems LogonType = oItem.LogonType If LogonType=="2" || LogonType=="10" Then UserLogonTime = StrSub(oItem.StartTime,1,14) Next UserLogonTime = FormatDate(UserLogonTime) ; Explorer Start Time oItems = oWMI.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'explorer.exe'") ForEach oItem In oItems ExplorerStartTime = StrSub(oItem.CreationDate,1,14) Next ExplorerStartTime = FormatDate(ExplorerStartTime) Message("LastBootTime",LastBootTime) Message("UserLogonTime",UserLogonTime) Message("ExplorerStartTime",ExplorerStartTime)
Article ID: W18489
Filename: Retrieve Last Boot Time - User Logon Time - Explorer Start Time .txt
File Created: 2008:10:28:08:14:36
Last Updated: 2008:10:28:08:14:36