Witto Posted June 20, 2007 Share Posted June 20, 2007 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 More sharing options...
Witto Posted June 20, 2007 Author Share Posted June 20, 2007 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 More sharing options...
Mast3rpyr0 Posted June 20, 2007 Share Posted June 20, 2007 I think this will do the trick While ProcessExists ( "IExplorer.exe" ) ProcessClose ( "IExplorer.exe" ) WEnd My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
Witto Posted June 21, 2007 Author Share Posted June 21, 2007 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? Link to comment Share on other sites More sharing options...
Witto Posted June 21, 2007 Author Share Posted June 21, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now