Sign in to follow this  
Followers 0
Keithdib

Uninstall Script

14 posts in this topic

Hi

I am trying to write a script that will uninstall a software package. the package generates a different ProductCode on each machine and each time its installed so I cannot use this as a reference.

I have been using _RegSearch [with help from PsaltyDS]

what I need is a script that would work something like,

$www = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

$xxx = "DisplayName"

$yyy = "DisplayVersion"

$zzz = "UninstallString"

search on the above then give the UninstallString as an other variable to then allow "Msiexec /X $mmm....etc" to be run

thanks

Share this post


Link to post
Share on other sites



$www = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")

$www = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","Valuename")

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Hi

thanks for speedy reply, but this will only ready entries with names such as Abobe, Microsoft etc it will not read entries with starting and ending {}

thanks

Keith

Share this post


Link to post
Share on other sites

"the package generates a different ProductCode on each machine and each time its installed"

I'm not sure what you mean by that.

Regardless of the productcode, its installation and uninstallation registry entries should still be at the same location.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Sorry I ment ProductGuid

The package leaves registry entries

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CruuentVersion\Unnstall\{this string is different each time} ....i.e no vendor name

therefore I need to search within all the entries for SoftwareID or DisplayName & DisplayVersion, then I need the UninstallString from within

thanks

Share this post


Link to post
Share on other sites

Perhaps this helps

$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

For $i = 1 To 99999
    $tempkey = RegEnumKey($key, $i)
    If @error Then ExitLoop
    $Displayname = RegRead($key & $tempkey, "DisplayName")
    $UninstallString = RegRead($key & $tempkey, "UninstallString")
    ConsoleWrite($UninstallString & @LF & $Displayname & @LF & $tempkey & @LF & @LF)
Next

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Thanks forumer100

I have changed it very slightly to

$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"

For $i = 1 To 99999

$tempkey = RegEnumKey($key, $i)

If @error Then ExitLoop

$Displayname = RegRead($key & $tempkey, "DisplayName")

$DisplayVersion = RegRead($key & $tempkey, "DisplayVersion")

$UninstallString = RegRead($key & $tempkey, "UninstallString")

ConsoleWrite($Displayname & @LF & $DisplayVersion & @LF & $UninstallString & @LF & @CRLF & @CRLF)

Next

however it still does not display keys that use {} only names...

the app all ways installs as {this string changes}

thanks

Keith

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hi Keithdib,

Hope the below code may give some help! The below code will read all the registry keys and it's uninstall valude from under it.s Uninstall registry key.

#include"Array.au3" 
Global $a 
Global $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 
Global $key64 = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" 
Global $val = "uninstallstring" 
Dim $a = 1 
Dim $List[1] 
Dim $Display[1] 
$i = 1 
$val = "uninstallstring" 




While 1 
$array = RegEnumKey($key, $a) 
$array2 = RegRead($key & "\" & $array, "uninstallstring") 
If $array <> "" Then 
$a += 1 
$Display[$i - 1] = RegRead($key & "\" & $array, "DisplayName") 
If $Display[$i - 1] = "" Then $Display[$i - 1] = "Display Name is not Found" 
$List[$i - 1] = $array2 
If $List[$i - 1] = "" Then $List[$i - 1] = "No Uninstall Key Found" 
$List[$i - 1] = $List[$i - 1] & '|' & $Display[$i - 1] 
ReDim $List[UBound($List) + 1] 
ReDim $Display[UBound($Display) + 1] 
$i += 1 
Else 
ExitLoop 
EndIf 
WEnd 
_ArrayDisplay($Display) 
_ArrayDisplay($List)
Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Hi Syed23

Is there a reason 2 arrays need to be used?

keith

Share this post


Link to post
Share on other sites

Hi Syed23

Is there a reason 2 arrays need to be used?

keith

i feel that could be better to handle Display name; Uninstall string; This is just sample code.. you can modify as you want :)


Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites

Thanks forumer100

I have changed it very slightly to

..........

however it still does not display keys that use {} only names...

the app all ways installs as {this string changes}

I forgot the x64 installers. Here the modified code:

$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
For $i1 = 1 To 2
    ConsoleWrite(@LF & @LF & "*******" & $key & "*************" & @LF & @LF)
    For $i = 1 To 99999
        $tempkey = RegEnumKey($key, $i)
        If @error Then ExitLoop
        $Displayname = RegRead($key & $tempkey, "DisplayName")
        If @error Then ContinueLoop
        $msg = "Key:  " & $tempkey & @LF
        $msg &= "DispName: " & $Displayname & @LF
        $DisplayVersion = RegRead($key & $tempkey, "DisplayVersion")
        $msg &= "DispVersion: " & $DisplayVersion & @LF
        $UninstallString = RegRead($key & $tempkey, "UninstallString")
        $msg &= "Uninstall: " & $UninstallString & @LF
        ConsoleWrite($msg & @LF & @LF)
    Next
    $key = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
Next

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

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