erikpd
(Fresh Scripter)
2009-03-27 12:07 AM
Failed Uninstall Code - I'm on a mission to remove everything

So far I've managed to write successful uninstall routines for both LimeWire and BitTorrent thanks to a lot of help from you guys.

Using those scripts I attempted to write ones for WeatherBug, Google Toolbar v6, and Yahoo! Toolbar, all with poor results. Actually I did get a WeatherBug uninstaller to work, but it was completely different code then what I initially set out to do, I'll illustrate below.

Here is my unsuccessful WeatherBug uninstall attempt. It would launch the uninstall routine, but then it wouldn't do anything else. Basically my SendKeys functions wouldn't work, but when I manually pressed the key it would work fine:

 Code:
;*************************************************************************
;  Script Name:   WeatherBug Removal
;  Author:        Erik Dunbar
;  Date:          3/26/2009
;  Description:   Script to silently automate the uninstall wizard of WeatherBug.
;*************************************************************************
 
BREAK ON

; Declare variables first
Dim $Rc                   ; Used to trap return codes
Dim $Cmd                  ; command string used for SHELL
$TimeToDie = @TICKS + 5000 ; 5 seconds from now

; set Script Options to enforce good habits
$Rc = SetOption("Explicit", "ON")
$Rc = SetOption("NoMacrosInStrings", "ON")
$Rc = SetOption("NoVarsInStrings", "ON")

; launch the uninstaller
$Cmd = 'MsiExec.exe /X{70DECFBF-9119-4434-B2D3-A3C283D15E45}'
'Running ' $Cmd ?
Shell $Cmd

While @TICKS < $TimeToDie And SetFocus('Windows Installer')
  Sleep 1
Loop
If @TICKS > $TimeToDie
  'failed to launch uninstaller!' ?
  Exit 1
EndIf

Sleep 1

$Rc = SendKeys('Y')


This next code below is the WeatherBug uninstall that actually worked. I stole the idea from somewhere on the boards:

 Code:
;*************************************************************************
;  Script Name:   WeatherBug Removal
;  Author:        Erik Dunbar
;  Date:          3/26/2009
;  Description:   Script to silently automate the uninstall wizard of WeatherBug.
;*************************************************************************
 
BREAK ON

; set Script Options to enforce good habits
$Rc = SetOption("Explicit", "ON")
$Rc = SetOption("NoMacrosInStrings", "ON")
$Rc = SetOption("NoVarsInStrings", "ON")

Shell "MsiExec.exe /norestart /qn /x {70DECFBF-9119-4434-B2D3-A3C283D15E45} REMOVE=ALL"


The same thing happens with both Google Toolbar and Yahoo! Toolbar. I can get the wizards to launch, but the SendKeys functions don't work.

Google Toolbar code:
 Code:
;*************************************************************************
;  Script Name:   Google Toolbar Removal
;  Author:        Erik Dunbar
;  Date:          3/26/2009
;  Description:   Script to silently automate the uninstall wizard of Google Toolbar.
;*************************************************************************
 
BREAK ON

; Declare variables first
Dim $Rc                   ; Used to trap return codes

; set Script Options to enforce good habits
$Rc = SetOption("Explicit", "ON")
$Rc = SetOption("NoMacrosInStrings", "ON")
$Rc = SetOption("NoVarsInStrings", "ON")

; launch the uninstaller
Shell 'Msiexec.exe /X{18455581-E099-4BA8-BC6B-F34B2F06600C}'

$Rc = SendKeys('N')


Yahoo Toolbar code:
 Code:
;*************************************************************************
;  Script Name:   Yahoo Toolbar Removal
;  Author:        Erik Dunbar
;  Date:          3/26/2009
;  Description:   Script to silently automate the uninstall wizard of Yahoo Toolbar.
;*************************************************************************
 
BREAK ON

; Declare variables first
Dim $Rc                   ; Used to trap return codes
Dim $Cmd                  ; command string used for SHELL
$TimeToDie = @TICKS + 5000 ; 5 seconds from now

; set Script Options to enforce good habits
$Rc = SetOption("Explicit", "ON")
$Rc = SetOption("NoMacrosInStrings", "ON")
$Rc = SetOption("NoVarsInStrings", "ON")

; launch the uninstaller
Shell '%PROGRAMFILES%\Yahoo!\Common\UNYT_W~1.EXE'
$Rc = SendKeys('y')
Sleep 3
$Rc = SendKeys('C')


Glenn BarnasAdministrator
(KiX Supporter)
2009-03-27 12:41 AM
Re: Failed Uninstall Code - I'm on a mission to remove everything

SendKeys is not a very reliable method, as you're quickly finding out. The problem is that you can setfocus to one window, but another will launch, run, and close, but focus isn't returned to your original window. And, that's just one of many issues.

Uninstalling apps requires a few bits of knowledge - what are the commands to run the uninstall, what arguments will do it silently, and where are the commands located on computer.

The first two often require a bit of digging with Google or your favorite search engine. Use keywords like "Unattended" and "Uninstall" with the product name.

Kix can definitely help with the third part, as it can scrape and search the registry for clues to the install path and such.. get comfortable with MSIExec's options, as they are pretty universal. Use your Weatherbug method as a sample.

Glenn