Sign in to follow this  
Followers 0
Witto

Terminate Internet Explorer

5 posts in this topic

This is my first trial in AutoIT to automate an installation. The installation requires that Internet Explorer is closed on the computer. I would like to enumerate all processes on the computer, select all iexplore.exe from the list and end these processes

This is how far I got

Dim $strComputer, $objWMIService, $colProcessList, $objProcess, $colMax, $Nr
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colProcessList = $objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'iexplore.exe'")
$colMax = UBound($colProcessList)
For $Nr = 0 To $colMax Step 1
    $objProcess = $colProcessList[$Nr]
    $RC = $objProcess.Terminate()
Next

This is the error I get

Illegal text at the end of statement (one statement per line).: 
$objProcess = $colProcessList[$Nr] 
$objProcess = $colProcessList^ ERROR
>Exit code: 1   Time: 0.316

I would presume $colProcessList is a collection or array.

Any ideas how to enumerate via WMI all iexplore.exe processes on a computer and terminate them?

Share this post


Link to post
Share on other sites



After some testing in more familiar scripting languages, I think the $colProcessList[$Nr] is not supported.

I have the impression that a "For Each ... in ... Next" does not exist in AutoIT

would someone be able to translate the following KiXtart script?

Break On
Dim $RC, $strComputer, $objWMIService, $colProcessList, $objProcess
$strComputer = "."
$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\cimv2")
$colProcessList = $objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'notepad.exe' OR Name = 'freecell.exe'")
For Each $objProcess in $colProcessList
    $RC = $objProcess.Terminate()
Next

Share this post


Link to post
Share on other sites

While ProcessExists ( "IExplore.exe" )
    ProcessClose ( "IExplore.exe" )
WEnd

Thanks, that will do the trick!

AutoIT does not have a "For Each ... Next" loop or something similar?

Share this post


Link to post
Share on other sites

I am affraid it will not do.

When using alternate credentials (p.e. RunAsSet() ) and there is no profile yet for the alternate user on the computer, it starts nagging about how the Phishing Philter for Internet Explorer 7 should be set.

ProcessClose("iexplorer.exe") fails at this point. But the WMI script would not fail and just close Internet Explorer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0