Jump to content

Running loop silently to catch bogus dialog


beato
 Share

Recommended Posts

I'm performing an automated/unattended uninstall => within a function its looping through the reg and reading the uninstall key etc..However, for whatever reason at one point I get a stubborn windows MSI error dialog the stops the entire routine from running until "OK" is pressed. The dialog appears twice within this function and that's it.

The only way I can think of is to create a real simple looping EXE which would be kicked off at the start of the function (which would run silently in the background) before the main loop that starts the uninstall logic and wait until the MSI dialog appears two times then exit.

Like this:

Func bla, bla, bla()

Run Dialog_catcher.exe ;' this would be the silent loop 

While 1 
    performing main uninstall stuff here
WEnd



"Dialog_catcher.exe" would be something like this, which I am having problems with as I want it to exit it after the two dialogs closed:

While 1 
    $ans = WinActivate("Windows Installer")
            Send("{ENTER}")
    If $ans < 2 Then ExitLoop
WEnd

Thoughts?

Link to comment
Share on other sites

an Adlib as such with a proper wintitle

AdlibRegister ("_adlib_check", 1000)

func _adlib_check()
    local $wintitle = "Windows Installer"
    ; activate the window if it exists
    if winexists ($wintitle) and not winactive ($wintitle) then
        winactivate ($wintitle)
        sleep (500)
    endif
    ; send enter if the window is active
    if winactive ($wintitle) then
        send ("{enter}")
        sleep (1000)
    endif
endfunc
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

an Adlib as such with a proper wintitle

AdlibRegister ("_adlib_check", 1000)

func _adlib_check()
    local $wintitle = "Windows Installer"
    ; activate the window if it exists
    if winexists ($wintitle) and not winactive ($wintitle) then
        winactivate ($wintitle)
        sleep (500)
    endif
    ; send enter if the window is active
    if winactive ($wintitle) then
        send ("{enter}")
        sleep (1000)
    endif
endfunc

Great, that looks interesting, but I'm not familiar with this function/how to use. Would have any suggestions on how to use that function inside my main function?:

Func All_Uninstall()
    If FileExists("C:\Progra~1\Network Associates") Then
        RunWait(@ComSpec & " /C " & 'net stop "mcshield"')
        RunWait(@ComSpec & " /C " & 'NET stop "Network Associates McShield"')
    EndIf
    If FileExists("C:\Program Files (x86)\McAfee") Then
        RunWait(@ComSpec & " /C " & 'NET STOP "McAfee McShield"')
    EndIf
;~ Uninstall all MSI types. Add or remove names from list========================
    Dim $MyApps[3] = ["App1, App2, App3"]
    $InstalledAppsCount = 1
    $Found = 0
        While 1
            $SubKey = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $InstalledAppsCount)
            If @error Then ExitLoop

            $DisplayName = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $SubKey, "DisplayName")
            $Uninstallstring = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $SubKey, "UninstallString")

            For $i = 0 To UBound($MyApps)-1
                If StringInStr($DisplayName, $MyApps[$i]) And StringInStr($Uninstallstring, "MsiExec", 0) Then
                    $Found += 1
                    If Not StringInStr($Uninstallstring, "/qb") And Not StringInStr($Uninstallstring, "/qn") Then $Uninstallstring &= " /qb"
                    GUICtrlSetData($StatusLabel, "Uninstalling msi's...")
                    RunWait(StringReplace($Uninstallstring,"/I{","/X{"),"")
                EndIf ; < I "think" right here is when I get the the dialog I want to answer OK > It happens after App2 and then after App3
            Next
            $InstalledAppsCount += 1
        WEnd
    Sleep(2000)
EndFunc

Thanks again for all of your assistance :)

Link to comment
Share on other sites

Adlib helpfile might be of more assistance but, in my example it runs that function every second. So I wouldnt put it inside your main function so much as just adding the adlibregister at the top so that it is running while you are doing your stuff.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...