mdwerne Posted February 3, 2011 Share Posted February 3, 2011 I'm working on a Java cleanup utility and one of the first steps is to close all open browsers. Firefox, Opera, Chrome and Safari all close and re-open without issue...but IE 8 generates an error when I re-open it stating "Your last browsing session closed unexpectedly" the two options are "Restore your last session" or "Go to your home page" Here is the close code I've tried...all variations give me the same error on re-launch of IE. Does anyone have a suggestion as to how I can close IE (and all open IE tabs) gracefully? Thanks for your time, -Mike expandcollapse popupFunc CloseApps() $CloseApps = GUICtrlCreateLabel("Closing Java and all Internet Browsers, please wait...", 300, 330, 450, 25) GUICtrlSetFont(-1, 12, 800, 0, "Georgia") GUICtrlSetColor(-1, 0xFF0000) ;CLOSE JAVA While ProcessExists("jqs.exe") ProcessClose("jqs.exe") WEnd While ProcessExists("Javaw.exe") ProcessClose("Javaw.exe") WEnd While ProcessExists("Java.exe") ProcessClose("Java.exe") WEnd ;CLOSE BROWSERS Dim $aIE[1] $aIE[0] = 0 Dim $i = 1 While 1 Dim $oIE = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIE $aIE[0] = $i $i += 1 _IEQuit($oIE) WEnd ;~ While 2 ;~ If ProcessExists("IEXPLORE.exe") Then ;~ ProcessClose("IEXPLORE.exe") ;~ EndIf ;~ If Not ProcessExists("IEXPLORE.exe") Then ;~ ExitLoop ;~ EndIf ;~ WEnd ;~ While 1 ;~ ProcessClose("iexplore.exe") ;~ Global $pid = ProcessExists("iexplore.exe") ;~ If $pid Then ProcessClose($pid) ;~ WEnd While ProcessExists("Iexplore.exe") ProcessClose("Iexplore.exe") WEnd While ProcessExists("Firefox.exe") ProcessClose("Firefox.exe") WEnd While ProcessExists("Safari.exe") ProcessClose("Safari.exe") WEnd While ProcessExists("Chrome.exe") ProcessClose("Chrome.exe") WEnd While ProcessExists("Opera.exe") ProcessClose("Opera.exe") WEnd Sleep(3000) EndFunc ;==>CloseApps Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 3, 2011 Share Posted February 3, 2011 Don't close the process. You should _IEAttach() in a loop and do _IEQuit() on each instance instead. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mdwerne Posted February 10, 2011 Author Share Posted February 10, 2011 Don't close the process. You should _IEAttach() in a loop and do _IEQuit() on each instance instead. So this is ugly, but it seems to work. #include <IE.au3> While ProcessExists("Iexplore.exe") GetIE() WEnd Exit Func GetIE() Dim $aIE[1] $aIE[0] = 0 $i = 1 While 1 $oIE = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIE $aIE[0] = $i $i += 1 _IEQuit($oIE) sleep(500) WEnd EndFunc ;==>GetIE One side affect is that I get this warning from the console. --> IE.au3 V2.4-0 Warning from function _IEAttach, $_IEStatus_NoMatch Thanks for the suggestion... -Mike 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