Page 1 of 1 1
Topic Options
#193211 - 09/03/27 12:07 AM Failed Uninstall Code - I'm on a mission to remove everything
erikpd Offline
Fresh Scripter

Registered: 09/03/17
Posts: 5
Loc: Washington, DC
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')

Top
#193212 - 09/03/27 12:41 AM Re: Failed Uninstall Code - I'm on a mission to remove everything [Re: erikpd]
Glenn Barnas Moderator Offline
KiX Supporter
*****

Registered: 03/01/28
Posts: 4205
Loc: New Jersey
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
_________________________

Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 131 anonymous users online.
Newest Members
OKCPCS, mprell, Dad24Lads, Cutebear, kstieers
17434 Registered Users

Generated in 0.027 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org