Results 1 to 17 of 17

Thread: [RESOLVED] How to get process information

  1. #1

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Resolved [RESOLVED] How to get process information

    Hey guys...me again

    I am using the following to check for running processes on remote machines:

    VB Code:
    1. Function IsProcessRunning( strServer, strProcess )
    2.     Dim Process, strObject
    3.     IsProcessRunning = False
    4.     strObject   = "winmgmts://" & strServer
    5.     For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
    6.     If UCase( Process.name ) = UCase( strProcess ) Then
    7.             IsProcessRunning = True
    8.             Exit Function
    9.         End If
    10.     Next
    11. End Function

    It works with no problems.

    What I want to know is how to get more information besides just the name of the process.

    How do I find out the user that is running the processes on the remote machine?
    I've tried using Process.User, Process.UserID, Process.UserName, etc.. and can't get anything.

    I appreciate the help
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    You can use "Process.ProcessId" to get its process id.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Thanks,
    Wouldn't that just give me this though: (PID)
    Attached Images Attached Images  
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    Yes.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Quote Originally Posted by RobDog888
    Yes.
    Well, thanks..but I don't need the Process ID. I need to find out the username of the person running the process
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    Ok, I thought you were just asking for any other info you could get out of it.

    Let me see what else I can find on those.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Thanks RobDog...I appreciate it
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    Ok, here we go. This will enumerate the running processes (local or remote) and identify the account that its running under/
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Dim strComputer As String
    5.     Dim sReturn As String
    6.     Dim strNameOfUser As Variant
    7.     Dim colProcesses As Object
    8.     Dim objProcess As Object
    9.     strComputer = "." '"." local or "\\ComputerName"
    10.     Set colProcesses = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select * from Win32_Process")
    11.     For Each objProcess In colProcesses
    12.         sReturn = objProcess.GetOwner(strNameOfUser)
    13.         If sReturn <> 0 Then
    14.             MsgBox "Could not get owner info for process " & objProcess.Name & vbNewLine & "Error = " & sReturn
    15.         Else
    16.             MsgBox "Process " & objProcess.Name & " is owned by " & "\" & strNameOfUser & "."
    17.         End If
    18.     Next
    19. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    I'll give that a shot tonight and see how it works.

    Thanks for such a quick reply. I knew there was a reason I keep coming here
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    I thought members hung out here for the the atmosphere?

    It works great on my system (XP) and I just tested it (from XP system) to retrieve info from my 2003 Server and it works great I think I did a good job (pats self on back ).
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Quote Originally Posted by RobDog888
    I thought members hung out here for the the atmosphere?

    It works great on my system (XP) and I just tested it (from XP system) to retrieve info from my 2003 Server and it works great I think I did a good job (pats self on back ).
    Yes, you do a great job

    I ran into a problem. The problem is, I can't get it to work using what you posted, but I have been working on this program for several months and have this function heavily built into it:
    VB Code:
    1. Function IsProcessRunning( strServer, strProcess )
    2.     Dim Process, strObject
    3.     IsProcessRunning = False
    4.     strObject   = "winmgmts://" & strServer
    5.     For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
    6.     If UCase( Process.name ) = UCase( strProcess ) Then
    7.             IsProcessRunning = True
    8.             Exit Function
    9.         End If
    10.     Next
    11. End Function

    Can you show me how to get the user name information using this? Same concept, but I tried with the Process.GetOwner() as you mentioned, but on every machine, it only brought back a "0". I can get the info via command prompt so I know I have rights to it (plus I'm the local/network admin)

    Like I said, this function is heavily built into what I've already done so I want to use it if possible without having to rewrite the whole program. Maybe even help me modify it a little without totally changing it.

    My program looks for a list or running processes like this:
    VB Code:
    1. Public Sub CheckRunning()
    2.     On Error GoTo errhand
    3.     Dim strComputer, strProcess
    4.     lstPrograms.Clear
    5.     strComputer = lstComputers.Text
    6.         strProcess = "notepad.exe"
    7.     If (IsProcessRunning(strComputer, strProcess) = True) Then
    8.         lstPrograms.AddItem "Notepad" & " " & "is running"
    9.     Else
    10.         lstPrograms.AddItem "Notepad" & " " & "is Not running"
    11.     End If
    12. 'snip a large number of repetitive lines here

    Can you help

    Thanks
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  12. #12

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Hey RobDog888

    Where'd ya go? I haven't figured this out yet
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    I was working on my block walls around my backyard.

    I'll look at your code and see whats happening.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: How to get process information

    Ok, I incorporated my previous example into yours.
    VB Code:
    1. Option Explicit
    2.  
    3. Function IsProcessRunning(strServer, strProcess)
    4.     Dim strNameOfUser As Variant
    5.     Dim Process, strObject
    6.     IsProcessRunning = False
    7.     strObject = "winmgmts://" & strServer
    8.     strNameOfUser = strServer
    9.     For Each Process In GetObject(strObject).InstancesOf("win32_process")
    10.         If UCase(Process.Name) = UCase(strProcess) Then
    11.             Process.GetOwner (strNameOfUser)
    12.             MsgBox strNameOfUser
    13.             IsProcessRunning = True
    14.             Exit Function
    15.         End If
    16.     Next
    17. End Function
    18.  
    19. Private Sub Form_Load()
    20.     IsProcessRunning "MyServer", "System"
    21. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Quote Originally Posted by RobDog888
    Ok, I incorporated my previous example into yours.
    VB Code:
    1. Option Explicit
    2.  
    3. Function IsProcessRunning(strServer, strProcess)
    4.     Dim strNameOfUser As Variant
    5.     Dim Process, strObject
    6.     IsProcessRunning = False
    7.     strObject = "winmgmts://" & strServer
    8.     strNameOfUser = strServer
    9.     For Each Process In GetObject(strObject).InstancesOf("win32_process")
    10.         If UCase(Process.Name) = UCase(strProcess) Then
    11.             Process.GetOwner (strNameOfUser)
    12.             MsgBox strNameOfUser
    13.             IsProcessRunning = True
    14.             Exit Function
    15.         End If
    16.     Next
    17. End Function
    18.  
    19. Private Sub Form_Load()
    20.     IsProcessRunning "MyServer", "System"
    21. End Sub
    Tried it, still getting nothing. I have tried it on XP Pro and XP home.

    any ideas?
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  16. #16

    Thread Starter
    Hyperactive Member Capp's Avatar
    Join Date
    May 2005
    Location
    Texas
    Posts
    409

    Re: How to get process information

    Quote Originally Posted by Capp
    Tried it, still getting nothing. I have tried it on XP Pro and XP home.

    any ideas?

    I got it...

    VB Code:
    1. Function IsProcessRunning(strServer, strProcess)
    2.     Dim strNameOfUser As String 'changed it to string to display text
    3.     Dim Process, strObject
    4.     IsProcessRunning = False
    5.     strObject = "winmgmts://" & strServer
    6.     strNameOfUser = strServer
    7.     For Each Process In GetObject(strObject).InstancesOf("win32_process")
    8.         If UCase(Process.Name) = UCase(strProcess) Then
    9.             Call Process.GetOwner (strNameOfUser) 'called function
    10.             MsgBox strNameOfUser
    11.             IsProcessRunning = True
    12.             Exit Function
    13.         End If
    14.     Next
    15. End Function
    AmazingAntivirus.com
    Remote Data Backups


    Please Mark your Thread "Resolved", if the query is solved...

    If a post has helped you then Please Rate it!

  17. #17
    New Member
    Join Date
    Oct 2007
    Posts
    2

    Re: [RESOLVED] How to get process information

    RobDog can u help me in making AntiKeyLogger in VB,VB.net

Posting Permissions

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



Click Here to Expand Forum to Full Width