0

WMI: VBscript to enumerate all processes on a computer

Posted February 3rd, 2010 in processes and tagged , , , , , , , , , , by dirk adamsky

Ok, let’s put in another one..
The script creates a list of all prcesses on a computer.
Default computer is the local machine.
When the dot is replaced by another machine name the script works against that machine.
There are some conditions that must be met:

  1. the script must be run with administrative credentials
  2. the firewall of the remote machine needs the following ports opened for WMI: TCP 135, TCP 4168 and
    UDP 9256

Follow the next steps to make and run the script (admin rights needed):

  • open your favorite text editor (mine is notepad++)
  • copy and paste the script into the editor (delete the line numbers)
  • save the script (for example c:templistprocesses.vbs)
  • open a command prompt
  • go to “c:temp”
  • give “cscript listprocesses.vbs” (without quotes) and enter

The script:

' Name : listprocesses.vbs
' Description : script to enumerate all processes on a computer
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 03-02-2010
' Level : beginner

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process")
For Each Item In colItems
	Wscript.Echo Item.Name
Next
Set colItems = Nothing
Set objWMIService = Nothing

As said earlier: when you have questions/problems please give a reply.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV


Related Posts:
  • Active Directory and WMI: VBscript to enumerate the ntfs rights of a given UNC path and a given level of subfolders
  • WMI: VBscript to show the network shares of a computer
  • Active Directory: VBscript to enumerate the local profile size of all computers and users in Active Directory

  • Leave a Reply