Jump to content

How to: Bypass error/failure in Uninstalls


Silverel
 Share

Recommended Posts

Hey there. Love these forums, they've helped me out tons in the past weeks as I've been learning AutoIt.

I'm writing a script to uninstall a handful of programs. Upon initial testing with some client PC's, we found one of the uninstallers was broken, and I need a way to bypass the whole section of code and report it when the script finishes. Ideally, something to add to each section for the same functionality would be great. I've been digging through the forums and the help file trying to find a way, hopefully asking a question here will net quicker results.

CODE
; Uninstalls Enterprise Provisioning Suite Direct!

runas ($sUserName, @ComputerName, $sPassword, 0, "C:\Program Files\InstallShield Installation Information\{332C4D4B-E595-405D-9C32-26AC38464BC3}\setup.exe")

WINWAITactive ("InstallShield Wizard", "&Next >")

send ("r")

send ("{ENTER}")

winwaitactive ("Confirm File Deletion", "OK")

send ("{ENTER}")

winwaitactive ("Shared File Detected", "&Yes")

send ("{ENTER}")

winwaitactive ("InstallShield Wizard", "Finish")

send ("{down}")

send ("{ENTER}")

runas ($sUserName, @ComputerName, $sPassword, 0, "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,1")

WinWaitActive ("System Properties", "Network Identification")

send ("r")

send ("{TAB}{TAB}{TAB}")

send($domain)

send("{ENTER}")

Winwaitactive ("Domain Username And Password", "&Name:")

send($domuser)

send("{TAB}")

send($dompass)

send("{ENTER}")

WinWaitActive ("Network Identification", "Welcome")

send ("{ENTER}")

WinWaitActive ("Network Identification", "reboot")

send("{ENTER}")

WinWaitActive ("System Properties", "Network Identification")

send ("{TAB}{TAB}{ENTER}")

_FileCreate($sFilePath)

WinWaitActive ("System Settings Change", "&No")

send("y")

There are other uninstalls that I left out to save on space, and stay relevant. The second section is the end of the script which changes the domain and restarts the PC. The FileCreate simply drops a 0k text file as an identifier for another script that needs to run afterwards.

Another aspect would be to identify which uninstalls were bypassed, and log them to a text file. Just more things that I'm not familiar with. I'd imagine the first step would be to create $Paths for them, but I'm not sure how I would use them to accomplish my goals.

Help is much appreciated. :mellow:

Link to comment
Share on other sites

Several things may help:

  • You can find uninstall info in the registry, which gives you a path to the uninstall string to use for the app you trying to uninstall.
  • You can also see if the uninstaller has command line switches to make the whole thing MUCH easier to automate. InstallShield commonly uses switches. To see what switch to use, run the uninstall with /?. Many times it will give you a GUI with the list of available switches.
  • Look at using controlsend instead of send. Makes things more stable.
Good work on what you have done so far.
Link to comment
Share on other sites

Several things may help:

  • You can find uninstall info in the registry, which gives you a path to the uninstall string to use for the app you trying to uninstall.
  • You can also see if the uninstaller has command line switches to make the whole thing MUCH easier to automate. InstallShield commonly uses switches. To see what switch to use, run the uninstall with /?. Many times it will give you a GUI with the list of available switches.
  • Look at using controlsend instead of send. Makes things more stable.
Good work on what you have done so far.

Thanks :mellow:

All the uninstall strings are pulled from the registy. I'm not sure how I would parse that information from within AutoIt, but the code works so far. It's just an error with the app uninstall, not the code.

Only 2 of the programs use InstallShield, and those are indeed done with switches.

Ah... Whats the difference between ControlSend and Send? Would I be able to just replace the Send commands with ControlSend with the current code?

Link to comment
Share on other sites

Controlsend will send to the window you want, no matter if it is active or not. This will make it more stable in that if your current script loses focus to the window you want to command to be sent to, the thing would still work. Currently, you lose window focus, the script breaks.

To parse the information to AutoIt, use RegRead to get the info, then use run with the correct string.

Link to comment
Share on other sites

I'm not exactly sure how If statements work in AutoIt, but would this bit of code work?

CODE
runas ($sUserName, @ComputerName, $sPassword, 0, "C:\Program Files\InstallShield Installation Information\{332C4D4B-E595-405D-9C32-26AC38464BC3}\setup.exe")

if WINactive ("InstallShield Wizard", "&Next >")

Then send ("r")

send ("{ENTER}")

winwaitactive ("Confirm File Deletion", "OK")

send ("{ENTER}")

winwaitactive ("Shared File Detected", "&Yes")

send ("{ENTER}")

winwaitactive ("InstallShield Wizard", "Finish")

send ("{down}")

send ("{ENTER}")

else _FileCreate ($EPSDFail)

EndIf

I would test it if I could...

Link to comment
Share on other sites

I fixed it up a bit, and added a sleep to allow for the app to open.

runas ($sUserName, @ComputerName, $sPassword, 0, "C:\Program Files\InstallShield Installation Information\{332C4D4B-E595-405D-9C32-26AC38464BC3}\setup.exe")
sleep(5000) ;allows for app to open if there. You may want to look at ProcessExist
if WinActive ("InstallShield Wizard", "&Next >") Then
send ("r")
send ("{ENTER}")
winwaitactive ("Confirm File Deletion", "OK", 30)
send ("{ENTER}")
winwaitactive ("Shared File Detected", "&Yes", 30)
send ("{ENTER}")
winwaitactive ("InstallShield Wizard", "Finish", 30)
send ("{down}")
send ("{ENTER}")
else 
_FileCreate ($EPSDFail)
EndIf
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...