vbscript: how can I use the process id to get a windows handle

I can capture all the process ids for a client under test, but I currently at a loss on how to convert those ids into window handles.

Process Id Code
Function ProcessId
   'capture the hwnd  from all windows with a certain caption
set objService = getobject("winmgmts:")
		For each Process in objService.InstancesOf("Win32_process")   
			If  Process.Name = "FronTIER.exe" Then
						ret = msgbox(Process.processid, vbOkCancel)
If ret = vbCancel Then
							ExitTest micWarning
						End If
			End If

End Function

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

From command prompt:

>tasklist | findstr <PID>
Darrell PorterEnterprise Business Process ArchitectCommented:

ret = msgbox(Process.processid, vbOkCancel)


ret = msgbox("ProcessID:" & Process.processid & "; Handle:" " & Process.handle, vbOkCancel)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ART_Mac03Author Commented:
let me try this. I do not know I could not think of this simple solution.

I need to my code simple due to my users; your solution can be what they would like.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

ART_Mac03Author Commented:
typo: I do not know why I did not think of this solution.
ART_Mac03Author Commented:
The solution was helpful especially since the info. displayed to my user community was direct and non-complex.
I eventually found a different way to solve my org. problem with using Process IDs to determine Window handles. I am using the test tool QTP to capture the windows object data based on the Swfname of the application or the object name of a feature in the app.  I pass the object name based on the process ID/name of the process.
ART_Mac03Author Commented:
thanks for both solutions.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.