![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Get window title from PID On some of my devices, I have a application that my users have that attaches them to one particular system, while they are in that system they need to run various IE windows that will interface, communicate, etc. We have created a VBScript that monitors when they are attached to the system and when that EXE is closed will close all of the open IE windows. Because of the way these devices are used, we don't want them opening IE windows except when they are attached to that particular system and our script work beautifully in that respect. BUT - There is also another IE window that is normally open on the device that is locked to a specific site/url that we don't care if they are attached to the other system when they are using. How do I NOT kill that particular IE window? I think that testing for the window title - which does not change or the site url/ipaddress would be best but I am at a loss on how to gather this information. I am currently using the following code: Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'myprogram.exe'") if colProcessList.count > 0 then Set colProcessList2 = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'iexplore.exe'") if colProcessList2.count > 0 then objProcess2.Terminate() ******* end if end if what I would like to do is change the line marked with ******* to something like this: if title is not <blah> or url is not <xyz.com> then objProcess2.Terminate() end if I can obviously get the process id, is there any way to use that to gather the necessary information? Any thoughts? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Get window title from PID I can't see a specific way to get the window title from the PID, but based on your description - and my assumption that you're doing this from a locally running WSH script or HTA - there's an easier way to handle the problem. Go in through simple IE window enumeration using a Shell.Application COM object instance. Here's a demo of a simple script that first culls out the desktop windows that are for filesystem browsing, then checks the LocationUrl property for each of the other windows. If it is "about:blank", they are closed. One other fringe benefit of this approach is that if you ever move to tabbed browsers, this code isn't going to break due to accidentally close the hidden "parent" IE container. To adapt it to your situation, you probably want to use another loop like the one that checks for "file:", only using a short unique initial substring that identifies the site you don't mind leaving open. set sa = CreateObject("Shell.Application") Set windows = sa.Windows() for each window in sa.windows if left(window.LocationUrl, 5) <> "file:" then ' logic for selecting windows goes here if window.locationUrl = "about:blank" then window.Quit() end if next <roger.pray@xxxxxx> wrote in message news:7133fdf5-805b-4f1b-8ccc-fd08c7563b68@xxxxxx Quote: > On some of my devices, I have a application that my users have that > attaches them to one particular system, while they are in that system > they need to run various IE windows that will interface, communicate, > etc. > > We have created a VBScript that monitors when they are attached to the > system and when that EXE is closed will close all of the open IE > windows. > > Because of the way these devices are used, we don't want them opening > IE windows except when they are attached to that particular system and > our script work beautifully in that respect. > > BUT - There is also another IE window that is normally open on the > device that is locked to a specific site/url that we don't care if > they are attached to the other system when they are using. > > How do I NOT kill that particular IE window? I think that testing for > the window title - which does not change or the site url/ipaddress > would be best but I am at a loss on how to gather this information. > > I am currently using the following code: > > Set colProcessList = objWMIService.ExecQuery ("Select * from > Win32_Process Where Name = 'myprogram.exe'") > if colProcessList.count > 0 then > Set colProcessList2 = objWMIService.ExecQuery ("Select * from > Win32_Process Where Name = 'iexplore.exe'") > if colProcessList2.count > 0 then > objProcess2.Terminate() ******* > end if > end if > > what I would like to do is change the line marked with ******* to > something like this: > > if title is not <blah> or url is not <xyz.com> then > objProcess2.Terminate() > end if > > I can obviously get the process id, is there any way to use that to > gather the necessary information? > > Any thoughts? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Activeate a window by hovering over it (THE TITLE BAR) with the mouse | Vista General | |||
| Please help with wierd problem - window stuck with title bar only | Vista General | |||
| Re-setting the window title when PSCX is installed | PowerShell | |||
| Updating window title bar to current location | PowerShell | |||
| How do I change the colours of window title bars? | Vista General | |||