WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

WMI
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

List Processes on a Remote Computer

 Keywords:  List Application Process Processes Remote Computer MACHINE

Sample Code:

;***************************************************************************
;** RemoteProcessList(ComputerName,Username,Password)
;** Returns a tab delimited list of all processes on a remote computer.
;** 
;** Parameters:
;** ComputerName: Computer name without \\, and "" for local.
;** UserName: User name to run program as
;** In format DOMAIN\User or just User for local, "" for current user running script.
;** MUST be "" for local computer or the function will fail.
;** Password: Password for user or "" if username is "".
;** 
;** Returns:
;** tab delimited list of all processes on a remote computer
;** 
;** 
;***************************************************************************
#DefineFunction RemoteProcessList(ComputerName,Username,Password)
list = ""
Locator = ObjectOpen("WbemScripting.SWbemLocator")
Service = Locator.ConnectServer(computername,"root/cimv2",username,password)
Security = Service.Security_
Security.ImpersonationLevel = 3
Instance = Service.InstancesOf("win32_process")
hEnum = ObjectCollectionOpen(Instance)
While 1
  Obj = ObjectCollectionNext(hEnum)
  If Obj == 0 Then Break
  list = StrCat(list,@tab,Obj.name)
EndWhile
list = StrTrim(list)
ObjectCollectionClose(hEnum)
ObjectClose(Instance)
ObjectClose(Security)
ObjectClose(Service)
ObjectClose(Locator)
Return list
#EndFunction

username = ""
password = ""
computername="SCOOBY"
list = RemoteProcessList(ComputerName,Username,Password)
AskItemList(StrCat("List of processes on ",computername),list,@tab,@unsorted,@single) 
exit

Article ID:   W15361
File Created: 2002:09:05:13:51:28
Last Updated: 2002:09:05:13:51:28