?
Solved

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

Posted on 2011-10-27
6
Medium Priority
?
2,366 Views
Last Modified: 2012-05-12
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
		
		Next

End Function

Open in new window

0
Comment
Question by:ART_Mac03
  • 4
6 Comments
 
LVL 13

Expert Comment

by:Govvy
ID: 37040926
From command prompt:

>tasklist | findstr <PID>
0
 
LVL 15

Accepted Solution

by:
WalkaboutTigger earned 1500 total points
ID: 37040962
Change

ret = msgbox(Process.processid, vbOkCancel)

to

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

Author Comment

by:ART_Mac03
ID: 37041477
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ART_Mac03
ID: 37041483
typo: I do not know why I did not think of this solution.
0
 

Author Closing Comment

by:ART_Mac03
ID: 37281046
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.
0
 

Author Comment

by:ART_Mac03
ID: 37281052
thanks for both solutions.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question