strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'explorer.exe'")
For Each item In colProcesses
WScript.Echo WMIDateStringToDate(item.CreationDate)
Next
Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
The VBS worked perfectly. The function to convert the date string worked well.
But each time we want to find a start time for a different task from the the task list we must modify the code. A commandline argument for the task name would improve an excellent solution.
Thanks for your help. The check is in the mail.
C:\>cat side.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & s
trComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Na
me = 'explorer.exe'")
For Each item In colProcesses
WScript.Echo WMIDateStringToDate(item.CreationDate)
Next
Function WMIDateStringToDate(dtmDate)
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dt
mDate,13, 2))
End Function
C:\>cscript side.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
11/24/2009 5:03:43 PM
C:\>
( But I guess all those times are at Boot time? )