Micro Focus QTP (UFT) Forums
How to create a script in QTP to get all the processes in a system - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to create a script in QTP to get all the processes in a system (/Thread-How-to-create-a-script-in-QTP-to-get-all-the-processes-in-a-system)



How to create a script in QTP to get all the processes in a system - NeemaNamia - 12-04-2012

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?


RE: How to create a script in QTP to get all the processes in a system - elango87 - 12-06-2012

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


RE: How to create a script in QTP to get all the processes in a system - Rashmi Vishwanath - 12-20-2012

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...


RE: How to create a script in QTP to get all the processes in a system - NeemaNamia - 12-21-2012

Thanks for the reply


RE: How to create a script in QTP to get all the processes in a system - elango87 - 12-24-2012

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


RE: How to create a script in QTP to get all the processes in a system - Rashmi Vishwanath - 01-08-2013

Thank U SmileSmile