| Author |
Topic  |
|
|
aval
Honorable But Hopeless Addict
    
USA
3276 Posts
Status: offline |
Posted - 07/31/2012 : 8:08:08 PM
|
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
3276 Posts
Status: offline |
Posted - 07/31/2012 : 8:40:12 PM
|
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
|
 |
|
|
aval
Honorable But Hopeless Addict
    
USA
3276 Posts
Status: offline |
|
|
aval
Honorable But Hopeless Addict
    
USA
3276 Posts
Status: offline |
Posted - 07/31/2012 : 10:28:44 PM
|
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 |
 |
|
|
JeffWouters
Here To Stay
 
Netherlands
147 Posts
Status: offline |
Posted - 08/01/2012 : 04:46:30 AM
|
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. |
 |
|
|
aval
Honorable But Hopeless Addict
    
USA
3276 Posts
Status: offline |
Posted - 08/01/2012 : 05:56:40 AM
|
I tried it both ways, with "PC1" and ".".
For the second script, I left it "." |
 |
|
|
Xenophane
Honorable But Hopeless Addict
    
Denmark
3070 Posts
Status: offline |
Posted - 08/01/2012 : 06:56:36 AM
|
| 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 |
 |
|
|
Xenophane
Honorable But Hopeless Addict
    
Denmark
3070 Posts
Status: offline |
Posted - 08/01/2012 : 07:03:00 AM
|
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 |
 |
|
|
aval
Honorable But Hopeless Addict
    
USA
3276 Posts
Status: offline |
Posted - 08/03/2012 : 8:30:34 PM
|
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? |
 |
|
|
Xenophane
Honorable But Hopeless Addict
    
Denmark
3070 Posts
Status: offline |
Posted - 08/04/2012 : 07:06:36 AM
|
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 |
 |
|
| |
Topic  |
|