Need to edge out the competition for your dream job? Train for certifications today.
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("c:\Program Files\Microsoft Office 2007\Office12\EXCEL.EXE")
strPID = objExec.ProcessID
Open in new window
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
strProcessName = "iexplore.exe"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT CreationDate,ProcessID FROM Win32_Process WHERE Name='" & strProcessName & "'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
intProcID = 0
dteStarted = CDate("01-01-1601")
For Each objItem In colItems
If CDate(WMIDateStringToDate(objItem.CreationDate)) > dteStarted Then
dteStarted = CDate(WMIDateStringToDate(objItem.CreationDate))
intProcID = objItem.ProcessId
If intProcID > 0 Then WScript.Echo "Process ID " & intProcID & " was started at " & dteStarted
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))
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment