Problem w/ Uninstall software in VBS/WMI

J

Joseph

I am using code I copy/pasted from the scrip center help file,
but the few lines below don't cut much mustard at all, it seems to
consider the request and then go to each name/software in
turnn and do nothing at all!

I am trying to automate the removal of unwanted software on clients'
machines and
love to get it to work.

Pointers to solution would be great, thank you all.

TIA

' These are the Names of Software I want to remove
' and as they appear in Control Panel -> Add/Remove Softyware:

Dim ArrOfProcessesToTerminate, strTargetProcToTerminate
ArrOfProcessesToTerminate = Array("iTunes","AdminScriptEditor TRIAL
EDITION","Clipomatic", _
"TheVoiceDot_Setup")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

For Each strTargetProcToTerminate In ArrOfProcessesToTerminate
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = '" &
strTargetProcToTerminate & "'")

For Each oProcess in colProcessList
wscript.popup "oProcess: " & ThisOne _
Chr(13) & "oProcess.InstallDate: " & oProcess.InstallDate _
Chr(13) & "oProcess.InstallLocation: " &
oProcess.InstallLocation _
Chr(13) & "oProcess.Name: " & oProcess.Name _
Chr(13) & "oProcess.Description: " & oProcess.Description
oProcess.Uninstall()

Next 'For Each oProcess In colProcesses

Next 'For Each strTargetProc In arrTargetProcs
 
B

Bill James

I think you must have 'On Error Resume Next' ahead of the code you show and that is killing the processing before you get to the popup. The line continuation format is not correct, you must use the ampersand when breaking up strings. Comment out the OERN and run the code to identify problems. Wscript.popup is also not valid, either create the wscript shell if you want to use popup, or change that to msgbox or wscript.echo.

--

Bill James
Microsoft MVP - Shell/User

Windows VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
 
J

Joseph

Bill,

Thank you very much for your comments.

I have made some changes and it works 'almost' as it should.
The problem now is that even using the WMICodeCreator, the WMI team were
kind enough to point me to,
does not retrieve all the programs installed on the PC, as can be seen in
the Add/Remove programs applet.

Why is that? Is there another way?

My ultimate prupose it to automate the removal of unwanted C**P like
Yahoo/Google/MyWebSearch toolbars which cause huges problems on my network,
but they don't seem to be seen..

TIA

Joseph.
I think you must have 'On Error Resume Next' ahead of the code you show and
that is killing the processing before you get to the popup. The line
continuation format is not correct, you must use the ampersand when breaking
up strings. Comment out the OERN and run the code to identify problems.
Wscript.popup is also not valid, either create the wscript shell if you want
to use popup, or change that to msgbox or wscript.echo.

--

Bill James
Microsoft MVP - Shell/User

Windows VBScript Utilities » www.billsway.com/vbspage/
Windows Tweaks & Tips » www.billsway.com/notes_public/
 
J

James Crosswell

Joseph said:
I have made some changes and it works 'almost' as it should.
The problem now is that even using the WMICodeCreator, the WMI team were
kind enough to point me to,
does not retrieve all the programs installed on the PC, as can be seen in
the Add/Remove programs applet.

That WMI class only lists software that was installed using Windows
Installer. The only way to get at the rest of the software products is
via the Registry...

For the purposes of displaying these products that probably wouldn't be
too difficult (I do this myself) - however if you actually want to do
something (like uninstall them) you've got your work cut out for you,
since these programs do not provide any uniform interface to do things
like uninstalling them. You could write lots of if statements:

if sProductName = 'SuperSpyware 2005' then
// Launch uninstaller for SuperSpyware 2005,
// which is the file ssuninst.exe in the
// program installation directory
else if sProductName = 'ReallyAnnoyingProduct 2' then
// etc.

Sound simple? Probably not eh, but that's the way it is.

--

Best Regards,

James Crosswell
Software Engineer
Microforge.net Limited
http://www.microforge.net
 
J

Joseph

Sound simple? Probably not eh, but that's the way it is.

I never said I was after simplicity, just clarity :)

Ah well.. I saw that MS uses the uninstall process sligthly different from
the script center help,
where instead of using objSoftware.Uninstall() they also use a more 'silent'
method like this:
Set objOutParams =
objWMIService.ExecMethod("Win32_Product.IdentifyingNumber='{6CE892F1-71A7-48C8-A72D-7C1A20436A6D}',Name='Microsoft
"Avalon" Beta 1 v6.0.4093.40928',Version='6.0.4093.40928'", "Uninstall")

So methink, maybe like you said I make up an uninstall string using the VBS
version using rundll32 -
err, you wouldn't happen tp know what that is by the way? I saw it a looong
time ago, and
didn't really know what to do with it at the time..!

TIA.
 
Joined
Apr 13, 2006
Messages
1
Reaction score
0
Hi,
Can you please give the whole script to remove software from add remove programs my id is (e-mail address removed) or (e-mail address removed)

That will be gr8 help!!

Thanks
Bhumika
 
Joined
Apr 13, 2006
Messages
1
Reaction score
0
Can I also have one please? My problem is the old version was manually installed, new version will deploy by GPO. Please send to (e-mail address removed). Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top