Micro Focus QTP (UFT) Forums

Full Version: How to create a script in QTP to get all the processes in a system
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried to fetch all the processess in a system using WMI and QTP is not recognising the object.Can anyone help me in getting the code to fetch the list of all the processes running in a system?
Below is code,

if you use "." for strComputer, it will fetch the details of the local machine.
If you want to fetch the list of process running in a remote machine, use the machine id in place of ".".
E.g.:

Code:
strComputer = "REMOTE-MACHINE100"
--
Dim Process, strComputer
Process = ""
strComputer = "."

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

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

count = 0
For Each objProcess in colProcess
    Process = Process + vbnewline + objProcess.Name
    count = count + 1
Next

Print Process

Set objWMIService = Nothing
Set colProcess = Nothing

Hope this helps...

Thanks,
Elango
HI for getting process of remotr machine its not fetching process... In case if its not fetching becuase of authentication issue.. let me know the code pls...
Thanks for the reply
If you are in a network, you should have access to the machine from which you are trying to fetch the processes. It wont work otherwise.

Thanks,
Elango
Thank U SmileSmile