Computer Hope
Microsoft => Microsoft DOS => Topic started by: Yogesh123 on November 24, 2009, 05:03:37 AM
-
Dear,
From tasklist i have got the list of running processes,
D:\Documents and Settings\administrator>tasklist
Image Name PID Session Name Session# Mem Usage
========================= ====== ================ ========
System Idle Process 0 Console 0 28 K
System 4 Console 0 68 K
winlogon.exe 1184 Console 0 3,644 K
services.exe 1228 Console 0 1,708 K
svchost.exe 1712 Console 0 13,936 K
explorer.exe 3316 Console 0 13,576 K
iexplore.exe 3856 Console 0 96 K
WINWORD.EXE 1680 Console 0 13,540 K
notepad.exe 2648 Console 0 224 K
Acrobat.exe 3304 Console 0 7,996 K
-------------------------------------------------------------------------------
but how do i read/findout the start time of any perticular process?
please advise,
Thanks in advance.
-
you can do this easily with vbscript
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'myprocess.exe'")
For Each item In colProcesses
WScript.Echo item.CreationDate
Next
-
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'myprocess.exe'")
For Each item In colProcesses
WScript.Echo item.CreationDate
Next
C:\>type casper.vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & s
trComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Na
me = 'SeaPort.exe'")
For Each item In colProcesses
WScript.Echo item.CreationDate
Next
C:\>cscript casper.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
20091124074757.765625-360
Is the above a start time for 'SeaPort.exe'
I cannot tell time.
-
Help, I get no output.
Probably not. The script is specifically looking for myprocess.exe. You should change this to whatever task you're looking for.
8)
-
cscript serverstats.vbs /s:atl-dc-01 /u:admin perf
cscript getevents.vbs atl-dc-01 "Directory Service"
ServerName = WScript.Arguments.Item(0)
EventLog = WScript.Arguments.Item(1)
EventID = WScript.Arguments.Item(2)
http://technet.microsoft.com/en-us/library/ee156618.aspx
No commandline arguments for task start time?
-
20091124074757.765625-360
Is the above a start time for 'SeaPort.exe'
I cannot tell time.
The date and time are in UTC format. To make it more readable you can plug this function into the script, make a reference to it, and you should be good to go:
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
Keep in mind that functions return a value.
No commandline arguments for task start time?
One of the perks of authoring a script is you get decide on the specifications and how it runs. Ghostdog decided not to allow for a command line argument. However you can do it yourself.
Using the script provided by Ghostdog plus the date format function, and the link you provided Command Line Arguments (http://technet.microsoft.com/en-us/library/ee156618.aspx), you have more than enough information to have the script accept a command line argument. Hint: Keep it simple and use an unnamed argument.
Good luck. 8)
-
One of the perks of authoring a script is you get decide on the specifications and how it runs. It was decided not to allow for a command line argument. However you can do it yourself.
Yogesh123 was the original poster with the question about task start times.
I have never written vbs.
I would like to see Sidewinder make the vbs start time a little easier to use for Yogesh123. Or can it be done with batch?
Thanks for your time.
-
I would like to see Sidewinder make the vbs start time a little easier to use for Yogesh123
Bill or Mike or whoever you choose to be today, your altruism is overwhelming.
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
I changed the process name to explorer.exe which should be present on most machines.
Or can it be done with batch?
Perhaps, but neither tlist or tasklist shows the CreationDate field on their output. In any case why would you want to use batch? Microsoft has already declared VBScript and JScript to be functionally stable (no more updates) although it is included with Windows 7. Microsoft meanwhile wants to drag everyone kicking and screaming to the Powershell bandwagon.
-
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? )
-
I would like to see Sidewinder make the vbs start time a little easier to use for Yogesh123.
i don't know about Sidewinder (i think he is very kind) , but I don't spoon feed people if i don't want to. If you are interested in vbs, go read up the docs and understand more. I only provide the fishing hook and teach how to fish. Not fish for you.
-
Very well put ghost
-
C:\>systeminfo
Host Name:
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 3 Build 2600
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Registered Owner:
Registered Organization:
Product ID:
Original Install Date: 5/7/2009, 3:55:05 PM
System Up Time: 0 Days, 2 Hours, 54 Minutes, 25 Seconds
-
Ike, all you're showing is you can copy, paste, and highlight red.
if the process was on startup, of course its going to say the system up time for it
-
process creation dates and system uptime are different things. A computer can be up for 4 hours, but a process can be created just minutes ago. Get that right.
-
process creation dates and system uptime are different things. A computer can be up for 4 hours, but a process can be created just minutes ago. Get that right.
We are discussing the processes listed by the tasklist command. ALL the processes listed by tasklist start at boot time.
You are sounding as Basic as "Basic"
-
taskmanager process start time read
the process start time, not which ones started with the computer
-
We are discussing the processes listed by the tasklist command.
then why are you using systeminfo command??
ALL the processes listed by tasklist start at boot time.
The CPUTIME filter option in tasklist is the total amount of CPU cycle time used by the process since its start, Although you can count those started by windows at start up as "since boot time", but processes started after boot time, for example, explorer.exe (when you double click it or launch from program manager) only can be viewed by tasklist with a command like this
tasklist /FI "CPUTIME gt hh:mm:ss"
that is, you have to manually give it a time to list those process you want. It doesn't show by default the processes start up time.
Get that right already