Sign in to follow this  
Followers 0
akorx

Uninstall all version of a program

16 posts in this topic

Hi,

It's again the little french... :P

I've to setup the last version of java on a lot of PC but before i must uninstall ALL version of this soft and each computer have some differents versions... it's there a way to unistall each version ?

I think i must do a "countdown uninstall" (i don't know how explain it in english :x ) in order to uninstall first, the last version (for exemple 1.6.0.17) and after the others (1.6.0.13, 1.6, 1.5, 1.2, etc)...

Do you have a idea to how to do this job ?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites



In AutoIt3, we have a command called Send.

It simulates keystrokes on a keyboard. Look at it in the help file.

Try to navigate the uninstall with the keyboard, writing down the keys you pressed, then once that is done, convert it into a send (more than one if you wish) command.

It is all in the help file.

shanet


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

In AutoIt3, we have a command called Send.

It simulates keystrokes on a keyboard. Look at it in the help file.

Try to navigate the uninstall with the keyboard, writing down the keys you pressed, then once that is done, convert it into a send (more than one if you wish) command.

It is all in the help file.

shanet

First, thanks for your reply... I can't use this solution because i'have got 300 computers and i want to do it in "silent mode"...


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

First, thanks for your reply... I can't use this solution because i'have got 300 computers and i want to do it in "silent mode"...

Yes, you can do it on 300 computers if you go around to them all and run it, or do you want to do something like uninstall off just 1 computer?


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

Yes, you can do it on 300 computers if you go around to them all and run it, or do you want to do something like uninstall off just 1 computer?

My computers are running a logon script when they are starting and i want to use this way, but the uninstall program MUST run in silent mode (i will use runas() fonction do to use administrator's right) because they don't have right to use the panel "add/remove" ...


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

My computers are running a logon script when they are starting and i want to use this way, but the uninstall program MUST run in silent mode (i will use runas() fonction do to use administrator's right) because they don't have right to use the panel "add/remove" ...

OK, you will want to insert this into your startup then.

Try ShellExecute("program uninstall exe path", "/silent, /uninstall or other uninstallation parameter")


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

I've got an idea : for each software, i've got a key "UninstallString" in "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", so i could take this value with Regread() and run it to uninstall the soft if the key "DisplayName" contains "java"... but how can i do to search in each "folder" in "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion" ?

It could be something like that :

For each key in "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

if Regread(StringInStr("displayname","java") then

runaswait(blablabla) in order to run msiexec /x HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\UninstallString

endif

Next

Can you help me ?


AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

Do you have any idea how many/which versions of Java you have in your environment? If it is three or four, and you know the specific versions, you can always write a simple For statement to include them all, such the this:

Local $var[3]
$var[0] = "{5BC8158C-08F7-4125-A831-AAFFDC8E4802}" ;1.3.1_08
$var[1] = "{7148F0A8-6813-11D6-A77B-00B0D0142120}"; 1.4.2
$var[2] = "{26A24AE4-039D-4CA4-87B4-2F83216022FF}" ;1.6.0.22

For $element in $var
    RunWait('msiexec /x "' & $element & '" /qn')
Next

The code will skip those that are not installed, and will uninstall any that are present.

If, however, you're dealing with rogue installations, and don't know how many/which versions of Java you have, the task will be more difficult.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

No i don't know how many versions i've got on each computer and which versions have been loaded (but i know that i've got 300 computers :x )... I think my script could be something like that :

#include <GUIConstants.au3>

#include <Constants.au3>

#include <Array.au3>

#Include <process.au3>

#include <File.au3>

#Include <string.au3>

#NoTrayIcon

For $i= 1 to 100000

$var = RegEnumKey("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i)

;MsgBox(4096, "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var, RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"DisplayName"))

If @error <> 0 then ExitLoop

If stringinstr(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"DisplayName"),"Java") then

$cle=RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"UninstallString")

If $cle <> "" then

MsgBox(4096, "SubKey #" & $cle & "", $cle)

RunAswait("administrator",@ComputerName,"*******",1,ShellExecuteWait($cle))

EndIf

EndIf

Next

Exit

If i run what the msgbox returns by hand in a cmd windows, it runs... but if autoit runs it with the runas() function, it does't and saids that it can't find the msiexec command... where is the problem ? i think that i can't run shellexecute with runas() function, is it the problem ?

NB : i MUST run the uninstall with administrator's rights. If you try my script try with your administrator's rights too !

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I think i've found a solution !!! i can replace :

RunAswait("administrator",@ComputerName,"*********4",1,ShellExecuteWait($cle))

by this :

$shell="ShellExecuteWait(" & $cle & ")"

MsgBox(4096, "MESSAGE", $shell)

RunAswait("administrator",@ComputerName,"*********",1,$shell)

I've no error but it doesn't uninstall java... i think i need a medic :x

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

Check this out. This is how i uninstall using WMI:

Func WMIService($host) ;Connects to WMI Service
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
    If not IsObj($objWMIService) Then return 0
    return $objWMIService
EndFunc

Func WMIQuery($objWMIService,$strWMIQuery) ;Perform WMI Query with Query String and Data Return Parameters
    $colItems = $objWMIService.ExecQuery($strWMIQuery)  ;Execute query against WMI Service Object
        For $objItem in $colItems
            MsgBox(0,"asdasd",$objitem.name)
;~          $objItem.Uninstall()
        Next
    return 1
EndFunc

$objWMIService = WMIService("localhost")  ;WMIService Object - Establish Connection
If $objWMIService = 0 Then Exit

;~ $soft1 = WMIQuery($objWMIService,"Select * from Win32_Product Where Name like '%Photoshop%'")  ;Run WMI Query against WMIService Object
$soft1 = WMIQuery($objWMIService,"Select * from Win32_Product Where Name like '%SUN%'")
If $objWMIService = 0 Then 
    MsgBox(0,"Error","An error have accured")
    Exit
    EndIf
    $objWMIService =  0
MsgBox(0,"Success","Uninstall compleeted successfully")

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

Nice, it's a very good work... but :

1) With my script :

#include <GUIConstants.au3>

#include <Constants.au3>

#include <Array.au3>

#Include <process.au3>

#include <File.au3>

#Include <string.au3>

#NoTrayIcon

For $i= 1 to 100000

$var = RegEnumKey("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", $i) ;MsgBox(4096, "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var, RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"DisplayName"))

If @error <> 0 then ExitLoop

If stringinstr(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"DisplayName"),"Java") then

$cle=RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"UninstallString")

If $cle <> "" then

;$shell="ShellExecuteWait(" & $cle & " /quiet)"

MsgBox(4096, "MESSAGE", $cle)

RunAswait("administrateur",@ComputerName,"xxxxxxxxx",1,$cle)

EndIf

EndIf

If stringinstr(RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"DisplayName"),"J2") then

$cle=RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" & "\" & $var,"UninstallString")

If $cle <> "" then

;$shell="ShellExecuteWait(" & $cle & " /quiet)"

MsgBox(4096, "MESSAGE", $cle)

RunAswait("administrateur",@ComputerName,"xxxxxxxx",1,$cle)

EndIf

EndIf

Next

Exit

=> It runs (i can see the progress bar) but the program is not uninstalled !!!!! is there a way to run a shellexecute with admin's right (it should be a "shellexecuteAS() but it doesn't exist))?

2) With your script : for exemple, i've got 3 versions of java installed (cf attachements) and i've modifiy your script like this :

$soft1 = WMIQuery($objWMIService,"Select * from Win32_Product Where Name like '%J2%' or Name like '%Java%'")

Why it doesn't uninstall java 1.2, i wish to know where it find "J2" or "java"... it's in registry ? which line?

install.doc

registry entries.doc

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

There is something wrong in may script or perhaps there is something that i don't understand... how does Windows to uninstall a soft??? i thought windows ALWAYS run just the key "UninstallString", but maybe is there another way or that it depends on the "setup program" used :x ?

For exemple the java 1.5.0_4 has this value (in the key "UninstallString") : MsiExec.exe /I{3248F0A8-6813-11D6-A77B-00B0D0150040}

To uninstall a msi, we should have a "/x" and i can't see it... so how does windows ?

Please help me guys !!!

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

I've found one thing : java 1.6 accepts "/x" to uninstall itself but others versions like 1.5 don't use this "/x" but open a windows and ask user to choice between "modify" or "delete"... and it's the reason why my script can't uninstall this kind of soft...

If i try the Juvigy's script it runs well for java1.5 or java1.6, but it doesn't uninstall java1.2... i think it doesn't find this soft in this request :

"Select * from Win32_Product Where Name like '%J2%' or Name like '%Java%' "

But why? which key does it reads to verify that it's a "%J2% or %Java% soft ? it's a little question, but i don't know the answer, can you help me guys :x ?

Edited by akorx

AkorxMail akorx@yahoo.fr

Share this post


Link to post
Share on other sites

Check this out. This is how i uninstall using WMI:

Func WMIService($host) ;Connects to WMI Service
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $host & "\root\cimv2")
    If not IsObj($objWMIService) Then return 0
    return $objWMIService
EndFunc

Func WMIQuery($objWMIService,$strWMIQuery) ;Perform WMI Query with Query String and Data Return Parameters
    $colItems = $objWMIService.ExecQuery($strWMIQuery)  ;Execute query against WMI Service Object
        For $objItem in $colItems
            MsgBox(0,"asdasd",$objitem.name)
;~          $objItem.Uninstall()
        Next
    return 1
EndFunc

$objWMIService = WMIService("localhost")  ;WMIService Object - Establish Connection
If $objWMIService = 0 Then Exit

;~ $soft1 = WMIQuery($objWMIService,"Select * from Win32_Product Where Name like '%Photoshop%'")  ;Run WMI Query against WMIService Object
$soft1 = WMIQuery($objWMIService,"Select * from Win32_Product Where Name like '%SUN%'")
If $objWMIService = 0 Then 
    MsgBox(0,"Error","An error have occured")
    Exit
    EndIf
    $objWMIService =  0
MsgBox(0,"Success","Uninstall completed successfully")

Had a look at this and cant get it to work for some reason i changed the %SUN% to %Google% and it brought up the google toolbar rubbish in IE on the prompt but it didnt uninstall it?

even though it said it completed succesfully.

Any thoughts on why?

And does Win32_Product cover 64 bit items as well?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0