Mark Minasi's Reader Forum
Mark Minasi's Reader Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Search | FAQ | Minasi Forum RSS Feed
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 HALP! Questions on Windows and Windows Server
 Scripting
 VBS script will not uninstall Java 6 update 33
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aval
Honorable But Hopeless Addict

USA
3272 Posts
Status: offline

Posted - 07/31/2012 :  8:08:08 PM  Show Profile  Reply with Quote
OK, this IS for Windows 2000 and I am attempting the procedure on a Windows 7 machine. That may be my problem.

http://technet.microsoft.com/en-us/library/ee176535.aspx

##################

strComputer = "PC1"
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_Product WHERE Name = 'Java(TM)6 update 33'")
For Each objSoftware in colSoftware
 objSoftware.Uninstall()
Next


###########################

But otherwise, even though I specify "PC1" as the computer name and "Java(TM)6 update 33" as the product name (just used what was in Add/Remove programs), nothing happens.

Literally nothing. Software remains installed and there's no error message. Nothing pertinent as far as I can see in Event Viewer.

aval
Honorable But Hopeless Addict

USA
3272 Posts
Status: offline

Posted - 07/31/2012 :  8:40:12 PM  Show Profile  Reply with Quote
This script does not work either:

#######################

'Start Script

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

'Uninstall Java(TM) 6 Update *
 Set colJava6dot = objWMIService.ExecQuery("Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'")
 For Each objSoftware in colJava6dot
 objSoftware.Uninstall()
 Next


######################

Yes, I trimmed the script shared here, since I only have Java 6 to contend with:

http://web2.minasi.com/forum/topic.asp?TOPIC_ID=39459
Go to Top of Page

aval
Honorable But Hopeless Addict

USA
3272 Posts
Status: offline

Posted - 07/31/2012 :  8:48:49 PM  Show Profile  Reply with Quote
Manual uninstall works fine though (although... I've had troubles in other cases).

Manual = Add/Remove Programs or "Programs".

So I just have to figure out what's happening behind the scenes and then reproduce that in a script.

Interestingly enough (?), it clears the Group Policy references in the registry, here:

http://serverfault.com/questions/111746/registry-key-location-for-software-deployed-via-group-policy

So nice and clean.
Go to Top of Page

aval
Honorable But Hopeless Addict

USA
3272 Posts
Status: offline

Posted - 07/31/2012 :  10:28:44 PM  Show Profile  Reply with Quote
OK, while I still would be interested in knowing why the above-mentioned .vbs scripts do not work, I seem to have attained my objective with a simple .bat script (as usual the .vbs gibberish seems less efficient than a one line .bat - or .ps1).

So... using the GUID found here (the value of the ProductID key):

Computer\HKLM\Software\Microsoft\Windows\CurrentVersion\GroupPolicy\AppMgmt\b837...f01\ProductID

I run the following script as a Startup Script in a GPO:

msiexec /x {GUID_from_location_above} /qn

-------------------------------------------

I *seem* to have a clean uninstall, i.e. references to the GPO removed as described here so a reinstall would be possible (if that's what you're after):

http://support.microsoft.com/kb/872969/en-us
Go to Top of Page

JeffWouters
Here To Stay

Netherlands
147 Posts
Status: offline

Posted - 08/01/2012 :  04:46:30 AM  Show Profile  Visit JeffWouters's Homepage  Click to see JeffWouters's MSN Messenger address  Look at the Skype address for JeffWouters  Reply with Quote
In the first script you've provided from the TechNet page, you changed the value of the strComputer variable from "." to "PC1".
Try using the "." as provided in the example on TechNet, this will use 'localhost' instead of the name you're forcing it to use.

By the way, mostly the easiest solution is the best... I like your solution where you look up the GUID and use msiexec :-D

Greetsz,
Jeff.
Go to Top of Page

aval
Honorable But Hopeless Addict

USA
3272 Posts
Status: offline

Posted - 08/01/2012 :  05:56:40 AM  Show Profile  Reply with Quote
I tried it both ways, with "PC1" and ".".

For the second script, I left it "."
Go to Top of Page

Xenophane
Honorable But Hopeless Addict

Denmark
3070 Posts
Status: offline

Posted - 08/01/2012 :  06:56:36 AM  Show Profile  Visit Xenophane's Homepage  Send Xenophane an ICQ Message  Reply with Quote
Have you tried it without UAC ?

Microsoft Powershell MVP

SIG> George Bernard Shaw : The power of accurate observation is commonly called cynicism by those who have not got it. </SIG>

You can read my blog at www.xipher.dk
Go to Top of Page

Xenophane
Honorable But Hopeless Addict

Denmark
3070 Posts
Status: offline

Posted - 08/01/2012 :  07:03:00 AM  Show Profile  Visit Xenophane's Homepage  Send Xenophane an ICQ Message  Reply with Quote
Just tested it in Powershell



$a = Get-WmiObject  -Query "Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'"
$a[1].Uninstall() 


Non Elevated prompt:
I get return code 1603, and nothing happens

Elevated Prompt:
I get return code 0, and it is uninstalled.



Microsoft Powershell MVP

SIG> George Bernard Shaw : The power of accurate observation is commonly called cynicism by those who have not got it. </SIG>

You can read my blog at www.xipher.dk

Edited by - Xenophane on 08/01/2012 07:03:46 AM
Go to Top of Page

aval
Honorable But Hopeless Addict

USA
3272 Posts
Status: offline

Posted - 08/03/2012 :  8:30:34 PM  Show Profile  Reply with Quote
No, I did not try it without UAC. Looks like that might have something to do with it.

quote:
$a = Get-WmiObject -Query "Select * from Win32_Product Where Name like 'Java(TM) 6 Update %'"
$a[1].Uninstall()



That is so concise!

And most of it is the WMI query.

$a[1].Uninstall()

So once you establish a value for that variable (is that the correct way to say it?), the "uninstall" method of (of what? WMI-Object?) removes the program.

But why $a[1] rather than just $a ?

Where does the 1 in brackets come from?
Go to Top of Page

Xenophane
Honorable But Hopeless Addict

Denmark
3070 Posts
Status: offline

Posted - 08/04/2012 :  07:06:36 AM  Show Profile  Visit Xenophane's Homepage  Send Xenophane an ICQ Message  Reply with Quote
Sorry about the confusion Aval

I assign the result of the WMI query to the variable $a, that will then contain either a single object, or a collection of objects (If the query returns multiple results)

I my case it returned 2 results because I had 2 editions of Java 6 on my machine.

In my case $a then contained a collection of 2 objects. So $a[1] just references the 2nd item in the collection. (First item is $a[0])

So if you wanted to remove all instances you should be able to do something like

$a | Foreach {$_.Uninstall()}

Microsoft Powershell MVP

SIG> George Bernard Shaw : The power of accurate observation is commonly called cynicism by those who have not got it. </SIG>

You can read my blog at www.xipher.dk
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Mark Minasi's Reader Forum © 2002-2011 Mark Minasi Go To Top Of Page
This page was generated in 0.14 seconds. Snitz Forums 2000