Home All Groups Group Topic Archive Search About

Removing applications using script



Author
10 May 2005 12:08 PM
Harrison Midkiff
Hello:

I am new to scripting.  I need to remove previous version of Adobe Acrobat
Reader in my organization.  I found the below script on the Microsoft
scripting center for removing an application.  Here I am trying to "Adobe
Acrobat 5.0".  I ran the script but it does not remove the program.  You can
see the name of the application is "Adobe Acrobat 5.0".  This is how the
name appears in Add/Remove Programs.  I can find any info if this is the
name I should use to remove the application.

Does anyone have experience removing an application like this?  How do you
get the correct name?

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

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Adobe Acrobat 5.0'")

For Each objSoftware in colSoftware
    objSoftware.Uninstall()
Next

Harrison Midkiff

Author
10 May 2005 2:05 PM
Yimin Wei
Harrison Midkiff wrote:
Show quote
> Hello:
>
> I am new to scripting.  I need to remove previous version of Adobe Acrobat
> Reader in my organization.  I found the below script on the Microsoft
> scripting center for removing an application.  Here I am trying to "Adobe
> Acrobat 5.0".  I ran the script but it does not remove the program.  You can
> see the name of the application is "Adobe Acrobat 5.0".  This is how the
> name appears in Add/Remove Programs.  I can find any info if this is the
> name I should use to remove the application.
>
> Does anyone have experience removing an application like this?  How do you
> get the correct name?
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
>     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colSoftware = objWMIService.ExecQuery _
>     ("Select * from Win32_Product Where Name = 'Adobe Acrobat 5.0'")
>
> For Each objSoftware in colSoftware
>     objSoftware.Uninstall()
> Next
>
> Harrison Midkiff
>
>

You can use this command on Windows XP or 2003 to find out the name.

wmic product get | find "Adobe"

If this is the first time you run wmic, it would take a while to
initialize. I don't have version 5.0 on my computer. The name for Adobe
Acrobat 7.0 is shown as "Adobe Reader 7.0".

Yimin Wei
Author
11 May 2005 3:36 PM
Torgeir Bakken (MVP)
Harrison Midkiff wrote:

> Hello:
>
> I am new to scripting.  I need to remove previous version of Adobe Acrobat
> Reader in my organization.  I found the below script on the Microsoft
> scripting center for removing an application.  Here I am trying to "Adobe
> Acrobat 5.0".  I ran the script but it does not remove the program.  You can
> see the name of the application is "Adobe Acrobat 5.0".  This is how the
> name appears in Add/Remove Programs.  I can find any info if this is the
> name I should use to remove the application.
>
> Does anyone have experience removing an application like this?  How do you
> get the correct name?
Hi

You can only use Win32_Product's Uninstall method for applications
that have been installed with Windows Installer.

AcroRead version 5.05 is not a Windows Installer installation but a
InstallShield installation, and can be uninstalled like this from a
script:

'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

sRegVal = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" _
       & "\Uninstall\Adobe Acrobat 5.0\UninstallString"

sARUninstall = ""
On Error Resume Next
sARUninstall = oShell.RegRead(sRegVal)
On Error Goto 0

If sARUninstall <> "" Then
   ' to make the uninstall unattended, add " -y -a"
   sARUninstall = sARUninstall & " -y -a"
   oShell.Run sARUninstall, 1, True
End If
'--------------------8<----------------------

--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

AddThis Social Bookmark Button