Aug 15th, 2005, 12:17 PM
#1
Thread Starter
Hyperactive Member
[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:
Function IsProcessRunning( strServer, strProcess )
Dim Process , strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process .name ) = UCase( strProcess ) Then
IsProcessRunning = True
Exit Function
End If
Next
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
Aug 15th, 2005, 12:25 PM
#2
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 15th, 2005, 12:39 PM
#3
Thread Starter
Hyperactive Member
Re: How to get process information
Thanks,
Wouldn't that just give me this though: (PID)
Attached Images
Aug 15th, 2005, 12:44 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 15th, 2005, 02:01 PM
#5
Thread Starter
Hyperactive Member
Re: How to get process information
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
Aug 15th, 2005, 02:03 PM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 15th, 2005, 02:06 PM
#7
Thread Starter
Hyperactive Member
Re: How to get process information
Thanks RobDog...I appreciate it
Aug 15th, 2005, 02:13 PM
#8
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:
Option Explicit
Private Sub Form_Load()
Dim strComputer As String
Dim sReturn As String
Dim strNameOfUser As Variant
Dim colProcesses As Object
Dim objProcess As Object
strComputer = "." '"." local or "\\ComputerName"
Set colProcesses = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2").ExecQuery("Select * from Win32_Process")
For Each objProcess In colProcesses
sReturn = objProcess.GetOwner(strNameOfUser)
If sReturn <> 0 Then
MsgBox "Could not get owner info for process " & objProcess.Name & vbNewLine & "Error = " & sReturn
Else
MsgBox "Process " & objProcess.Name & " is owned by " & "\" & strNameOfUser & "."
End If
Next
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 15th, 2005, 02:26 PM
#9
Thread Starter
Hyperactive Member
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
Aug 15th, 2005, 03:08 PM
#10
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 16th, 2005, 05:41 PM
#11
Thread Starter
Hyperactive Member
Re: How to get process information
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:
Function IsProcessRunning( strServer, strProcess )
Dim Process , strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
For Each Process in GetObject( strObject ).InstancesOf( "win32_process" )
If UCase( Process .name ) = UCase( strProcess ) Then
IsProcessRunning = True
Exit Function
End If
Next
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:
Public Sub CheckRunning()
On Error GoTo errhand
Dim strComputer, strProcess
lstPrograms.Clear
strComputer = lstComputers.Text
strProcess = "notepad.exe"
If (IsProcessRunning(strComputer, strProcess) = True) Then
lstPrograms.AddItem "Notepad" & " " & "is running"
Else
lstPrograms.AddItem "Notepad" & " " & "is Not running"
End If
'snip a large number of repetitive lines here
Can you help
Thanks
Aug 16th, 2005, 06:51 PM
#12
Thread Starter
Hyperactive Member
Re: How to get process information
Hey RobDog888
Where'd ya go? I haven't figured this out yet
Aug 16th, 2005, 08:30 PM
#13
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 16th, 2005, 11:29 PM
#14
Re: How to get process information
Ok, I incorporated my previous example into yours.
VB Code:
Option Explicit
Function IsProcessRunning(strServer, strProcess)
Dim strNameOfUser As Variant
Dim Process , strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
strNameOfUser = strServer
For Each Process In GetObject(strObject).InstancesOf("win32_process")
If UCase(Process .Name) = UCase(strProcess) Then
Process .GetOwner (strNameOfUser)
MsgBox strNameOfUser
IsProcessRunning = True
Exit Function
End If
Next
End Function
Private Sub Form_Load()
IsProcessRunning "MyServer", "System"
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
Aug 18th, 2005, 06:07 PM
#15
Thread Starter
Hyperactive Member
Re: How to get process information
Originally Posted by
RobDog888
Ok, I incorporated my previous example into yours.
VB Code:
Option Explicit
Function IsProcessRunning(strServer, strProcess)
Dim strNameOfUser As Variant
Dim Process , strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
strNameOfUser = strServer
For Each Process In GetObject(strObject).InstancesOf("win32_process")
If UCase(Process .Name) = UCase(strProcess) Then
Process .GetOwner (strNameOfUser)
MsgBox strNameOfUser
IsProcessRunning = True
Exit Function
End If
Next
End Function
Private Sub Form_Load()
IsProcessRunning "MyServer", "System"
End Sub
Tried it, still getting nothing. I have tried it on XP Pro and XP home.
any ideas?
Aug 18th, 2005, 06:13 PM
#16
Thread Starter
Hyperactive Member
Re: How to get process information
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:
Function IsProcessRunning(strServer, strProcess)
Dim strNameOfUser As String 'changed it to string to display text
Dim Process , strObject
IsProcessRunning = False
strObject = "winmgmts://" & strServer
strNameOfUser = strServer
For Each Process In GetObject(strObject).InstancesOf("win32_process")
If UCase(Process .Name) = UCase(strProcess) Then
Call Process .GetOwner (strNameOfUser) 'called function
MsgBox strNameOfUser
IsProcessRunning = True
Exit Function
End If
Next
End Function
Oct 10th, 2007, 11:59 PM
#17
New Member
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
Forum Rules
Click Here to Expand Forum to Full Width