Registered member login:
Register Now
Altirigos » Altiris Administrators » Scripts » Magic Uninstall VBS

» Current Poll
Do you leave the Aclient enabled?
YES - 82.31%
107 Votes
NO - 17.69%
23 Votes
Total Votes: 130
You may not vote on this poll.
» Stats
Members: 9,496
Threads: 11,750
Posts: 55,298
Top Poster: Nick (4,981)
Welcome our newest member, JessicaD
» Online Users: 57
2 members and 55 guests
Juice_IFF, Zizio82
Most users online at once 294, 06-30-2007 at 12:24 PM.
» March 2010
S M T W T F S
28 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 123
Reply
Old 04-28-2005, 01:00 PM   #1 (permalink)
 
TNeumann's Avatar
 
Status: SR Technical Acct Manager
Join Date: 02-17-2005
Location: Philadelphia
Posts: 1,494


Magic Uninstall VBS

I found this on the Altiris Forums & it looked worth taking a look at.

I use this script to uninstall programs based on the name they have in Add/Remove Programs (actually the value of HKLM\Software\Microsoft\Windows\CurrentVersion\{cl isid}\DisplayName)
since it uses the built in "Uninstall string" it doesn't matter how it was packaged.

It works best with MSIs though becasue it changes the /I to /x and defaults to msi command line options, but you can set them up however you want.

EDIT: Please drop me a line at dolan@ctc.com if you find this helpful, and please post any improvements that you have.

Thanks!

--------------------------------------------------------------------------
'------------------------------------------------------------------------------
' magic_uninstall.vbs
'------------------------------------------------------------------------------
' generic uninstaller script to uninstall applications based on the Add/Remove
' Programs DisplayName and UninstallString properties
'------------------------------------------------------------------------------
' Author: David M. Dolan
' Created: 4/19/2005
' Modified: 4/19/2005
'------------------------------------------------------------------------------
' Use this script for whatever you want -- I'm stating that there is no warranty
' and that I'm not responsible for any damage you do with it.
'------------------------------------------------------------------------------
' designed for use with MSI's but it should work on any other program that
' specifies and uninstall string -- but you have to miff out the /Options
' (" " works)
'------------------------------------------------------------------------------


'On error resume next

'------------------------------------------------------------------------------
' constants
'------------------------------------------------------------------------------
Const HKEY_LOCAL_MACHINE = &H80000002
Const KeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninsta ll"

'modify this if you want to, I default mine for MSIs, and if you're silly enough
' not to pass your own options and accidentally uninstall something, I want
' the dialog to pop up telling you what you just foobarred
const defaultOptions = "/qb+"
'------------------------------------------------------------------------------

'------------------------------------------------------------------------------
' read the command line paramters, and bomb out if there is a problem
'------------------------------------------------------------------------------
progToRemove = Wscript.Arguments.Named("Program")

MSIOptions = Wscript.Arguments.Named("Options")
if MSIOptions = "" then
MSIOptions = defaultOptions
end if


'------------------------------------------------------------------------------
' Main Program
'------------------------------------------------------------------------------
if progToRemove = "" then
usage
else

SeekAndDestroy

end if
Wscript.Quit(0)

'------------------------------------------------------------------------------
sub usage
'------------------------------------------------------------------------------
Wscript.Echo "usage: magic_uninstall.vbs /Program:<DisplayNameString> /Options:<commandlineopts>"
Wscript.Echo " ex: magic_uninstall.vbs /Program:""Orca"" /Options:""/qb-"""
Wscript.Quit(1)
end sub
'------------------------------------------------------------------------------
sub SeekAndDestroy
'------------------------------------------------------------------------------

set locator = CreateObject("WbemScripting.SWbemLocator")
set oWMI = locator.ConnectServer(".","root/default")


set objReg = oWMI.Get("StdRegProv")

lRC = objReg.EnumKey (HKEY_LOCAL_MACHINE, KeyPath, arrSubKeys)


'ok, so we're at the install key, loop through the sub keys...
For each Subkey in arrSubKeys

'look at the next key
newKeyPath = KeyPath & "\" & SubKey

'get all of the values and store them in two arrays -- value names in arrEntryNames
' -- value Types in to arrValueTypes
objReg.EnumValues HKEY_LOCAL_MACHINE,_
newKeyPath,arrEntryNames,arrValueTypes

'make sure we have an array, then grok it
if isArray(arrEntryNames) then

uninstallable = "f"

'loop through the entry names and keep the ones we're looking for
for i = 0 to Ubound(arrValueTypes)
entryName = arrEntryNames(i)

select case entryName

case "DisplayName"

'ok, display name, so what's the value? put it into sName
objReg.GetStringValue HKEY_LOCAL_MACHINE, _
newKeyPath, entryName, sName

case "DisplayVersion"
'ok, displayVersion, so store it into sVers

objReg.GetStringValue HKEY_LOCAL_MACHINE, _
newKeyPath, entryName, sVers

case "UninstallString"
objReg.GetStringValue HKEY_LOCAL_MACHINE, _
newKeyPath, entryName, sUninstall
uninstallable = "t"
end select

Next '-- value

if sName <> "" and uninstallable = "t" then

'ok so we know that we have a software name, and it's uninstallable, so
' only now do we check to see if it's what we're looking for...

if sName = progToRemove then

'this is where the magic happens
set oCmd = CreateObject("Wscript.Shell")

uninstallCommand = Replace(sUninstall, "/I", "/x") & " " & MSIOptions

commandLine = "%comspec% /c " & uninstallCommand

'wscript.echo commandLine

oCmd.Run commandLine, 0, true

Wscript.Quit(0) ' haha we're done, quit digging in the registry now!

end if

end if

end if

sName = ""
sVers = ""

Next '-- subKey

end sub
TNeumann is offline   Reply With Quote
Old 05-08-2005, 12:21 AM   #2 (permalink)
 
Nick's Avatar
 
Status: Altiris Architect (Site Founder)
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,981


Thanks for bringing this over Tim.
__________________
Scire potentia est (knowledge is power)
Nick is offline   Reply With Quote
Old 07-12-2005, 09:58 AM   #3 (permalink)
 
dave.dolan's Avatar
 
Status: the ultimate script kiddie
Join Date: 07-12-2005
Location: Pennsylvania
Age: 30
Posts: 192


checking in

Hey guys, I'm flattered to see this has been posted here. This one turned out to help me out of a serious jam. Let me know if you have any questions.


I noticed that there is a typo in that one, the constant line at the top shouldn't have a space between the two letter Ls at the end in the word "Uninstall"

--dave

Last edited by dave.dolan; 07-12-2005 at 10:01 AM..
dave.dolan is offline   Reply With Quote
Old 07-12-2005, 10:08 AM   #4 (permalink)
 
TNeumann's Avatar
 
Status: SR Technical Acct Manager
Join Date: 02-17-2005
Location: Philadelphia
Posts: 1,494


Dave,
I was gonna steal it for my own Has definitely helped me out as well, that's why I brought it over...hope you don't mind.
I went to edit the vbs text to remove the extra space, it shows up fine in the edit screen.
Where are you in PA?...not many of us around

Tim

Last edited by TNeumann; 07-12-2005 at 10:11 AM..
TNeumann is offline   Reply With Quote
Old 07-12-2005, 10:12 AM   #5 (permalink)
 
dave.dolan's Avatar
 
Status: the ultimate script kiddie
Join Date: 07-12-2005
Location: Pennsylvania
Age: 30
Posts: 192


Quote:
Originally Posted by TNeumann
Dave,
I was gonna steal it for my own Has definitely helped me out as well, that's why I brought it over...hope you don't mind.

Where are you in PA?...not many of us around

Tim
yeah Johnstown PA, about an hour or so from Pittsburgh. Alteeerse is how people around here say it, and it's like a dirty word to my management. I'm working very hard to change it. In rural PA we still think digital watches are a pretty neat idea.
dave.dolan is offline   Reply With Quote
Old 07-12-2005, 11:58 AM   #6 (permalink)
 
Nick's Avatar
 
Status: Altiris Architect (Site Founder)
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,981


Dave,

Welcome to the forums and if there is anything we can do to help you convince your management that Altiris isn't the Anti Christ let us know.

Also, don't be scared off by the fact that Tim is up there in PA with you. He's really not a bad guy once you get to know him, heck he even convinced some woman to marry him this year.
__________________
Scire potentia est (knowledge is power)
Nick is offline   Reply With Quote
Old 07-12-2005, 12:29 PM   #7 (permalink)
 
TNeumann's Avatar
 
Status: SR Technical Acct Manager
Join Date: 02-17-2005
Location: Philadelphia
Posts: 1,494


Johnstown really isn't part of PA. You have PA & Western PA lolol

I had to convince her AND pay her.
TNeumann is offline   Reply With Quote
Old 07-12-2005, 01:42 PM   #8 (permalink)
 
Nick's Avatar
 
Status: Altiris Architect (Site Founder)
Join Date: 01-01-2005
Location: RDU, North Carolina, USA
Posts: 4,981


Quote:
Originally Posted by TNeumann
I had to convince her AND pay her.
The interesting thing is that sentence is past tense. Being married myself I am inclined to believe that the paying NEVER stops.
__________________
Scire potentia est (knowledge is power)
Nick is offline   Reply With Quote
Old 08-28-2005, 10:17 AM   #9 (permalink)
 
Status: Altiris Admin
Join Date: 02-28-2005
Location: Richardson, TX
Posts: 88


Magic Uninstall Packaging Question

I have successfully configured this useful script, but am having trouble packaging it through SWD to execute on a client test machine. I am not a scripting expert, but am looking for a good way to uninstall programs via NS. The script file gets to the machine fine, but does not execute automatically. I suspect I am not using a good command line to execute it, or not packaging it correctly.
What am I missing??? Is there a best practice to packaging and executing scripts in the NS?
We are using CMS level I (not Wise solution).

Thanks
gdellaccio is offline   Reply With Quote
Old 08-28-2005, 11:46 AM   #10 (permalink)
 
Mike's Avatar
 
Status: Altiris Engineer (Super Mod)
Join Date: 02-22-2005
Location: South Jordan, Utah, USA
Posts: 1,196


Put the vbs in a folder that you identify as a "software delivery package" and specify a "Program" of cscript.exe vbsname.vbs

Remember that windows only knows how to execut a .com, .bat, or .exe. Anything else needs the help of one of these to get going.
__________________
______________________
Mike Ainsworth


Last edited by Mike; 08-31-2005 at 08:09 AM.. Reason: spelling error
Mike is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -4. The time now is 04:46 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
vB.Sponsors
Altirigos