+ Reply to Thread
Results 1 to 8 of 8

Taskmgr from VBA

Hybrid View

  1. #1
    Gary's Student
    Guest

    Taskmgr from VBA

    I can activate taskmgr from a macro by

    SHELL("c:\windows\system32\taskmgr.exe")

    How can I access the displayed process information, i.e. process name and
    PID, or get taskmgr to copy this information to a text file?
    --
    Gary's Student

  2. #2
    Vasant Nanavati
    Guest

    Re: Taskmgr from VBA

    Perhaps someone will prove me wrong, but I think you would need some
    sophisticated API trickery to do this.

    --

    Vasant


    "Gary's Student" <[email protected]> wrote in message
    news:[email protected]...
    > I can activate taskmgr from a macro by
    >
    > SHELL("c:\windows\system32\taskmgr.exe")
    >
    > How can I access the displayed process information, i.e. process name and
    > PID, or get taskmgr to copy this information to a text file?
    > --
    > Gary's Student




  3. #3
    Vasant Nanavati
    Guest

    Re: Taskmgr from VBA

    If you're really ambitious, you can try and adapt this for your needs (I
    tested it and it works but you may have to tweak it to get all the
    information you want):

    How to list running processes
    http://support.microsoft.com/default...b;en-us;187913

    --

    Vasant

    "Vasant Nanavati" <vasantn *AT* aol *DOT* com> wrote in message
    news:[email protected]...
    > Perhaps someone will prove me wrong, but I think you would need some
    > sophisticated API trickery to do this.
    >
    > --
    >
    > Vasant
    >
    >
    > "Gary's Student" <[email protected]> wrote in message
    > news:[email protected]...
    > > I can activate taskmgr from a macro by
    > >
    > > SHELL("c:\windows\system32\taskmgr.exe")
    > >
    > > How can I access the displayed process information, i.e. process name

    and
    > > PID, or get taskmgr to copy this information to a text file?
    > > --
    > > Gary's Student

    >
    >




  4. #4
    Gary's Student
    Guest

    Re: Taskmgr from VBA

    Thanks for your help Vasant. I'll give your reference a try. If I can get
    to a working API, then this will give me all that I need.

    Thanks again
    --
    Gary's Student


    "Vasant Nanavati" wrote:

    > If you're really ambitious, you can try and adapt this for your needs (I
    > tested it and it works but you may have to tweak it to get all the
    > information you want):
    >
    > How to list running processes
    > http://support.microsoft.com/default...b;en-us;187913
    >
    > --
    >
    > Vasant
    >
    > "Vasant Nanavati" <vasantn *AT* aol *DOT* com> wrote in message
    > news:[email protected]...
    > > Perhaps someone will prove me wrong, but I think you would need some
    > > sophisticated API trickery to do this.
    > >
    > > --
    > >
    > > Vasant
    > >
    > >
    > > "Gary's Student" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I can activate taskmgr from a macro by
    > > >
    > > > SHELL("c:\windows\system32\taskmgr.exe")
    > > >
    > > > How can I access the displayed process information, i.e. process name

    > and
    > > > PID, or get taskmgr to copy this information to a text file?
    > > > --
    > > > Gary's Student

    > >
    > >

    >
    >
    >


  5. #5
    Jim Cone
    Guest

    Re: Taskmgr from VBA


    Well it looks like "trickery" to me...

    '------------------------------
    'From... Ivan F Moala [email protected]
    ' public.excel.programming - March 20, 2004
    'With some minor changes by
    Jim Cone - San Francisco, USA
    '----------------------

    'WinXp / Xl2003
    '// WMI String Constants
    Private Const strWmgt As String = "winmgmts:" & _
    "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2"
    Private Const strWmiQ As String = "Select * from Win32_Process"

    Sub OwnerOfProcesses()
    Dim objWMIService As Object
    Dim colProcessList As Object
    Dim objProcess As Object
    Dim strNameOfUser As Variant 'JBC
    Dim strUserDomain As Variant 'JBC
    Dim colProperties As String
    Dim MyList() As Variant 'JBC
    Dim x As Long 'JBC

    Set objWMIService = GetObject(strWmgt)
    Set colProcessList = objWMIService.ExecQuery(strWmiQ)

    x = colProcessList.Count
    ReDim MyList(0 To (x - 1), 0 To 3) 'JBC
    x = 0

    For Each objProcess In colProcessList
    colProperties = objProcess.GetOwner(strNameOfUser, strUserDomain)
    MyList(x, 0) = objProcess.Name
    MyList(x, 1) = strUserDomain
    MyList(x, 2) = strNameOfUser
    MyList(x, 3) = objProcess.Handle
    x = x + 1
    Next

    With Range("A1:D1")
    .Value = Array("Process", "Domain", "User", "PID") 'JBC
    .Font.Bold = True
    End With
    Range("A2").Resize(x, 4).Value = MyList 'JBC
    Columns("A:D").AutoFit 'JBC
    MsgBox "Processes: " & x

    Set objWMIService = Nothing 'JBC
    Set colProcessList = Nothing 'JBC
    Set objProcess = Nothing 'JBC
    End Sub
    '--------------------------------------------


    "Gary's Student" <[email protected]> wrote in
    message news:[email protected]...
    I can activate taskmgr from a macro by
    SHELL("c:\windows\system32\taskmgr.exe")
    How can I access the displayed process information, i.e. process name and
    PID, or get taskmgr to copy this information to a text file?
    Gary's Student

  6. #6
    Vasant Nanavati
    Guest

    Re: Taskmgr from VBA

    Now that is pretty darned neat ... kudos to Ivan!

    --

    Vasant


    "Jim Cone" <[email protected]> wrote in message
    news:%[email protected]...
    >
    > Well it looks like "trickery" to me...
    >
    > '------------------------------
    > 'From... Ivan F Moala [email protected]
    > ' public.excel.programming - March 20, 2004
    > 'With some minor changes by
    > Jim Cone - San Francisco, USA
    > '----------------------
    >
    > 'WinXp / Xl2003
    > '// WMI String Constants
    > Private Const strWmgt As String = "winmgmts:" & _
    > "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2"
    > Private Const strWmiQ As String = "Select * from Win32_Process"
    >
    > Sub OwnerOfProcesses()
    > Dim objWMIService As Object
    > Dim colProcessList As Object
    > Dim objProcess As Object
    > Dim strNameOfUser As Variant 'JBC
    > Dim strUserDomain As Variant 'JBC
    > Dim colProperties As String
    > Dim MyList() As Variant 'JBC
    > Dim x As Long 'JBC
    >
    > Set objWMIService = GetObject(strWmgt)
    > Set colProcessList = objWMIService.ExecQuery(strWmiQ)
    >
    > x = colProcessList.Count
    > ReDim MyList(0 To (x - 1), 0 To 3) 'JBC
    > x = 0
    >
    > For Each objProcess In colProcessList
    > colProperties = objProcess.GetOwner(strNameOfUser, strUserDomain)
    > MyList(x, 0) = objProcess.Name
    > MyList(x, 1) = strUserDomain
    > MyList(x, 2) = strNameOfUser
    > MyList(x, 3) = objProcess.Handle
    > x = x + 1
    > Next
    >
    > With Range("A1:D1")
    > .Value = Array("Process", "Domain", "User", "PID") 'JBC
    > .Font.Bold = True
    > End With
    > Range("A2").Resize(x, 4).Value = MyList 'JBC
    > Columns("A:D").AutoFit 'JBC
    > MsgBox "Processes: " & x
    >
    > Set objWMIService = Nothing 'JBC
    > Set colProcessList = Nothing 'JBC
    > Set objProcess = Nothing 'JBC
    > End Sub
    > '--------------------------------------------
    >
    >
    > "Gary's Student" <[email protected]> wrote in
    > message news:[email protected]...
    > I can activate taskmgr from a macro by
    > SHELL("c:\windows\system32\taskmgr.exe")
    > How can I access the displayed process information, i.e. process name and
    > PID, or get taskmgr to copy this information to a text file?
    > Gary's Student




  7. #7
    Gary's Student
    Guest

    Re: Taskmgr from VBA

    Thank you both very much !!
    --
    Gary's Student


    "Vasant Nanavati" wrote:

    > Now that is pretty darned neat ... kudos to Ivan!
    >
    > --
    >
    > Vasant
    >
    >
    > "Jim Cone" <[email protected]> wrote in message
    > news:%[email protected]...
    > >
    > > Well it looks like "trickery" to me...
    > >
    > > '------------------------------
    > > 'From... Ivan F Moala [email protected]
    > > ' public.excel.programming - March 20, 2004
    > > 'With some minor changes by
    > > Jim Cone - San Francisco, USA
    > > '----------------------
    > >
    > > 'WinXp / Xl2003
    > > '// WMI String Constants
    > > Private Const strWmgt As String = "winmgmts:" & _
    > > "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2"
    > > Private Const strWmiQ As String = "Select * from Win32_Process"
    > >
    > > Sub OwnerOfProcesses()
    > > Dim objWMIService As Object
    > > Dim colProcessList As Object
    > > Dim objProcess As Object
    > > Dim strNameOfUser As Variant 'JBC
    > > Dim strUserDomain As Variant 'JBC
    > > Dim colProperties As String
    > > Dim MyList() As Variant 'JBC
    > > Dim x As Long 'JBC
    > >
    > > Set objWMIService = GetObject(strWmgt)
    > > Set colProcessList = objWMIService.ExecQuery(strWmiQ)
    > >
    > > x = colProcessList.Count
    > > ReDim MyList(0 To (x - 1), 0 To 3) 'JBC
    > > x = 0
    > >
    > > For Each objProcess In colProcessList
    > > colProperties = objProcess.GetOwner(strNameOfUser, strUserDomain)
    > > MyList(x, 0) = objProcess.Name
    > > MyList(x, 1) = strUserDomain
    > > MyList(x, 2) = strNameOfUser
    > > MyList(x, 3) = objProcess.Handle
    > > x = x + 1
    > > Next
    > >
    > > With Range("A1:D1")
    > > .Value = Array("Process", "Domain", "User", "PID") 'JBC
    > > .Font.Bold = True
    > > End With
    > > Range("A2").Resize(x, 4).Value = MyList 'JBC
    > > Columns("A:D").AutoFit 'JBC
    > > MsgBox "Processes: " & x
    > >
    > > Set objWMIService = Nothing 'JBC
    > > Set colProcessList = Nothing 'JBC
    > > Set objProcess = Nothing 'JBC
    > > End Sub
    > > '--------------------------------------------
    > >
    > >
    > > "Gary's Student" <[email protected]> wrote in
    > > message news:[email protected]...
    > > I can activate taskmgr from a macro by
    > > SHELL("c:\windows\system32\taskmgr.exe")
    > > How can I access the displayed process information, i.e. process name and
    > > PID, or get taskmgr to copy this information to a text file?
    > > Gary's Student

    >
    >
    >


  8. #8
    RB Smissaert
    Guest

    Re: Taskmgr from VBA

    You need Edanmo's task scheduler.
    Have a look at this website:
    http://www.mvps.org/emorcillo/en/code/vb6/index.shtml

    Go to: Using the Task Scheduler

    This is a VB dll file that makes all the properties and methods of the task
    scheduler available in VBA. I am using this and it works very well.

    RBS


    "Gary's Student" <[email protected]> wrote in message
    news:[email protected]...
    >I can activate taskmgr from a macro by
    >
    > SHELL("c:\windows\system32\taskmgr.exe")
    >
    > How can I access the displayed process information, i.e. process name and
    > PID, or get taskmgr to copy this information to a text file?
    > --
    > Gary's Student



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1