Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a process path and show modules loaded by a process

Status
Not open for further replies.

mefanning

MIS
Apr 26, 2010
19
US
I have two objectives with this vbscript that I am having trouble with.

1. I can get a list of running processes, but I cannot get the process path.
2. I would like to also see all of the modules loaded by a process. I can achieve this very easily with powershell, but I'm having trouble with vbscript.

My script is very basic so far...


Set objShell = CreateObject("WScript.Shell")

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")

For Each objProcess in colProcess

wscript.echo objprocess.path
Next

"Path" is not a valid property.

As mentioned, with PS, I can achieve very easily, but for this project it needs to be done in vbs.

PS equivelent: get-process | select -expand modules

Any help is appreciated. Thanks.
 
Ah, property is executable path.
Any ideas on how to list the loaded modules?
Modified code:

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")

For Each objProcess in colProcess

wscript.echo objProcess.Name & " " & objprocess.ExecutablePath

Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top