Jump to content

Uninstall Script


Recommended Posts

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

Link to comment
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.

Link to comment
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

Link to comment
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

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
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

Link to comment
Share on other sites

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]

Link to comment
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]

Link to comment
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

App: Au3toCmd              UDF: _SingleScript()                             

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...