Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: taskmanager process start time read  (Read 20183 times)

0 Members and 1 Guest are viewing this topic.

Yogesh123

    Topic Starter


    Beginner

    taskmanager process start time read
    « 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.

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: taskmanager process start time read
      « Reply #1 on: November 24, 2009, 05:16:31 AM »
      you can do this easily with vbscript
      Code: [Select]
      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

      MikeTaylor



        Rookie

        Re: taskmanager process start time read
        « Reply #2 on: November 24, 2009, 07:12:38 AM »

        Code: [Select]
        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.
        « Last Edit: November 24, 2009, 10:21:35 AM by MikeTaylor »
        Bill Richardson

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: taskmanager process start time read
        « Reply #3 on: November 24, 2009, 08:12:29 AM »
        Code: [Select]
        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)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        MikeTaylor



          Rookie

          Re: taskmanager process start time read
          « Reply #4 on: November 24, 2009, 11:00:06 AM »
          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?
          Bill Richardson

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: taskmanager process start time read
          « Reply #5 on: November 24, 2009, 12:33:48 PM »
          Quote
          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:

          Code: [Select]
          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.

          Quote
          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, 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)
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          MikeTaylor



            Rookie

            Re: taskmanager process start time read
            « Reply #6 on: November 24, 2009, 12:53:33 PM »

            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.
            Bill Richardson

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: taskmanager process start time read
            « Reply #7 on: November 24, 2009, 01:35:40 PM »
            Quote
            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.

            Code: [Select]
            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.

            Quote
            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.
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            MikeTaylor



              Rookie

              Re: taskmanager process start time read
              « Reply #8 on: November 24, 2009, 04:31:22 PM »


              Code: [Select]
              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? )
              Bill Richardson

              gh0std0g74



                Apprentice

                Thanked: 37
                Re: taskmanager process start time read
                « Reply #9 on: November 24, 2009, 06:13:44 PM »
                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.

                BatchFileBasics



                  Hopeful

                  Thanked: 18
                  Re: taskmanager process start time read
                  « Reply #10 on: November 24, 2009, 06:15:55 PM »
                  Very well put ghost
                  When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

                  MikeTaylor



                    Rookie

                    Re: taskmanager process start time read
                    « Reply #11 on: November 24, 2009, 07:01:23 PM »
                    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
                    Bill Richardson

                    BatchFileBasics



                      Hopeful

                      Thanked: 18
                      Re: taskmanager process start time read
                      « Reply #12 on: November 24, 2009, 07:06:12 PM »
                      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
                      When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

                      gh0std0g74



                        Apprentice

                        Thanked: 37
                        Re: taskmanager process start time read
                        « Reply #13 on: November 24, 2009, 07:07:48 PM »
                        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.

                        MikeTaylor



                          Rookie

                          Re: taskmanager process start time read
                          « Reply #14 on: November 24, 2009, 09:16:33 PM »
                          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"
                          Bill Richardson

                          BatchFileBasics



                            Hopeful

                            Thanked: 18
                            Re: taskmanager process start time read
                            « Reply #15 on: November 24, 2009, 09:39:13 PM »
                            taskmanager process start time read

                            the process start time, not which ones started with the computer
                            When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

                            gh0std0g74



                              Apprentice

                              Thanked: 37
                              Re: taskmanager process start time read
                              « Reply #16 on: November 24, 2009, 09:48:57 PM »
                              We are discussing the processes listed by the tasklist  command.
                              then why are you using systeminfo command??

                              Quote
                              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
                              Code: [Select]
                              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
                              « Last Edit: November 24, 2009, 09:59:30 PM by gh0std0g74 »