Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

wait for internetexplorer to terminate

$
0
0

Dear All,

this time something that sounds easy, but I do not find the "right" way to do it.

$ie=New-Object -comobject InternetExplorer.Application
$ie.visible=$true
$ie.Navigate( $url )

while($ie.busy){Start-Sleep 1}

do something, and at some point the user closes IE, because he has done ....

At his point my script should do something, but .... 

it should wait until IE exits

How can I do this ?

I tried :

Get-Process explorer | Foreach-Object { $_.WaitForExit() }

this blocks me powershell ...

this one gives an error message if IE is not running, which is not nice ....

while (  (Get-Process iexplore) ) {
 write "Running"
 sleep 5

}

Get-Process : Cannot find a process with the name "iexplore". Verify the process name and call the cmdlet again.
At line:2 char:22
+ while (  (Get-Process <<<<  iexplore) ) {
    + CategoryInfo          : ObjectNotFound: (iexplore:String) [Get-Process], ProcessCommandException
    + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand

 

any suggestions ?

 

Thx a lot

Eryk

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles