OliverGrey Posted February 13, 2019 Posted February 13, 2019 (edited) Greetings everyone. I'm an AutoIT newbie and was wondering if anyone has any tips on this topic or a code snippet they could share. I have a use-case for a population of Win10 computers which have an autologon account which stays logged in where multiple health care people use (Imprivata tap-in) and upon a different human user tapping into the device I need to gracefully close Edge if it is running. Currently I have VB scripts called via Imprivata that do process kills for previous user processes upon new login of a different user but I've found you should not kill the Edge process because if the prior user had multiple tabs they get restored for the next user upon browser launch. I've tried a couple of registry keys posted on the Internet about turning off Edge browser tab recovery but have not found anything that actually works. So I think I want to have Imprivata call an AutoIT script that does a simple window close [x] of Edge. I know the popup confirmation window of multiple tabs on close adds to the code complexity but I have no objection to using a registry key to turn off that prompt. Thanks in advance for any help. Tested the attached script which closes Edge if it is minimized but not if it not minimized. Edgeclose-test.au3 Edited February 14, 2019 by OliverGrey Tested a script that does not work
FrancescoDiMuro Posted February 13, 2019 Posted February 13, 2019 Hi @OliverGrey, and welcome to the AutoIt forums You can simply something like ProcessClose("iexplore.exe") to close your Internet Explorer session, without having the pop-up showing up Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Moderators JLogan3o13 Posted February 13, 2019 Moderators Posted February 13, 2019 Or, since you're asking for Edge and not IE: ProcessClose("MicrosoftEdge.exe") "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
OliverGrey Posted February 14, 2019 Author Posted February 14, 2019 I already tried ProcessClose. That's the same as a taskkill of the process which causes the tabs to be restored on next launch of Edge since Edge sees that as an app crash. I need to close the window, similar to clicking [X] in the browser.
FrancescoDiMuro Posted February 14, 2019 Posted February 14, 2019 (edited) @OliverGrey Doing this, and running this script, it does what you're looking for Global $arrWindows $arrWindows = WinList("[REGEXPTITLE:(?i).*\- Microsoft Edge]") For $i = 1 To $arrWindows[0][0] Step 1 ; Strange Behaviour - Even if the popup shows up, and the window(s) is/are not closed, the function returns 1 (tried with WinKill too) If WinClose($arrWindows[$i][1], $arrWindows[$i][0]) Then ConsoleWrite("Closing '" & $arrWindows[$i][0] & "' OK!" & @CRLF) Else ConsoleWrite("Closing '" & $arrWindows[$i][0] & "' ERR!" & @CRLF) EndIf Next Edited February 14, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
OliverGrey Posted February 14, 2019 Author Posted February 14, 2019 Yep! with the registry key AskToCloseAllTabs set to zero your AutoIT code works. Thank you for your help FrancescoDiMuro.
FrancescoDiMuro Posted February 14, 2019 Posted February 14, 2019 @OliverGrey You're welcome, and happy to have helped Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
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