Showtime2kX Posted December 27, 2012 Share Posted December 27, 2012 Hi, I have several AutoIT scripts that run installers for me (CCleaner, Malwarebytes, etc.). If I stop and close the installer before it finishes, it closes, but the AutoIT script continues to run in the background. I don't want to add in a timeout on my WinWaitActive commands because, to deal with computers that might be slow and are lagging, I didn't want that to accidentally time out when I'm running these on PCs that I'm repairing. Is there some other way besides using a timeout, to make the background process of the script close when I close the installer that it's running? Thanks in advance, Matt Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 Without seeing the code it's impossible to tell what you are talking about and where the problem is. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
PlayHD Posted December 27, 2012 Share Posted December 27, 2012 (edited) ProcessExists ? Edited December 27, 2012 by PlayHD My UDF : _WinShake, _WinSplitMy Apps : Google Guitar Bot, PuzzleGameDesign Gui : Interesting Tabs Design, RBox Project (abandoned), Animated Gui on Exit Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 If you need to run an installer and automate the install process by using AutoIt I wouldn't allow the user to cancel the install process.Use function BlockInput to block all user input by keyboard and mouse.Or - the way I prefer - use the command line switches of the software to do a silent install.The switches for CCleaner can be found here. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Showtime2kX Posted December 27, 2012 Author Share Posted December 27, 2012 Here is an example from my Malwarebytes installer: expandcollapse popup$MalwareBytes = "\Applications\Installers\Security Software\Anti-Malware\Malwarebytes\Newer Versions\malwarebytes.exe" Run($MalwareBytes) Sleep(2000) WinWaitActive("Select Setup Language", "English") Sleep(2000) WinActivate("Select Setup Language", "English") Sleep(2000) ProcessWait("malwarebytes.exe") ControlClick("Select Setup Language", "OK", "TNewButton1") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "&Next >") ControlClick("Setup - Malwarebytes Anti-Malware", "&Next >", "TNewButton1") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "License Agreement") ControlClick("Setup - Malwarebytes Anti-Malware", "I &accept the agreement", "TNewRadioButton1") Sleep(2000) ControlClick("Setup - Malwarebytes Anti-Malware", "&Next >", "TNewButton2") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "Please read the following important information before continuing.") ControlClick("Setup - Malwarebytes Anti-Malware", "&Next >", "TNewButton2") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "Select Destination Location") ControlClick("Setup - Malwarebytes Anti-Malware", "&Next >", "TNewButton3") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "Select Start Menu Folder") ControlClick("Setup - Malwarebytes Anti-Malware", "&Next >", "TNewButton4") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "Select Additional Tasks") ControlClick("Setup - Malwarebytes Anti-Malware", "&Next >", "TNewButton4") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "Ready to Install") ControlClick("Setup - Malwarebytes Anti-Malware", "&Install", "TNewButton4") Sleep(2000) WinWaitActive("Setup - Malwarebytes Anti-Malware", "Click Finish to exit Setup.") Send("{TAB}") Send("{SPACE}") Send("{TAB}") Send("{TAB}") Send("{SPACE}") ControlClick("Setup - Malwarebytes Anti-Malware", "&Finish", "TNewButton4") Sleep(2000) ProcessClose("malwarebytes.exe") Sleep(3000) Exit And it isn't "to stop a user" from cancelling the install. It is in case I accidentally ran it and needed to stop the install before it finishes. Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 The return value of Run is the PID of the process that was launched. So you could always check if the process you startet still exists:If Not ProcessExists($PID) Then Exit My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Showtime2kX Posted December 27, 2012 Author Share Posted December 27, 2012 Thanks. Where within the code should I place that If statement? Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 Guess! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 .. Before every statement that would "hang" your script. That means before every WinWait* function or every other function that will wait forever when the install process is no longer available. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Showtime2kX Posted December 27, 2012 Author Share Posted December 27, 2012 Certainly should add a bunch of extra lines to the code. I imagine there is no "cleaner" way. Thanks. Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 There is: AdLibregister. Will post an example later. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted December 27, 2012 Share Posted December 27, 2012 (edited) This should work too: $PID = Run(".....") AdlibRegister("_CheckProcess", 250) ; Your code goes here Func _CheckProcess() If Not ProcessExists($PID) Then exit EndFunc Edited December 27, 2012 by water wangf 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 27, 2012 Moderators Share Posted December 27, 2012 I imagine there is no "cleaner" way. There is a much "cleaner" way, use the silent switches as Water suggested in Post 4, and get your script down to this: ShellExecuteWait("CCleaner.exe", "/S") "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! Link to comment Share on other sites More sharing options...
Showtime2kX Posted December 28, 2012 Author Share Posted December 28, 2012 (edited) This should work too: $PID = Run(".....") AdlibRegister("_CheckProcess", 250) ; Your code goes here Func _CheckProcess() If Not ProcessExists($PID) Then exit EndFunc Awesome. This works great! Thanks a bunch, Matt Edited December 28, 2012 by Showtime2kX Link to comment Share on other sites More sharing options...
water Posted December 28, 2012 Share Posted December 28, 2012 Glad to be of service My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
wangf Posted February 15, 2013 Share Posted February 15, 2013 Mark, it is helpful Link to comment Share on other sites More sharing options...
guinness Posted February 16, 2013 Share Posted February 16, 2013 Mark, it is helpfulPlease refrain from doing this. If you want to 'mark' the post for later use e.g. when you get home, then use another method please instead of unnecessarily bumping. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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