Jump to content

Terminate Internet Explorer


Recommended Posts

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?

Link to comment
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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...