Jump to content
Sign in to follow this  
JohanV

Create silent uninstall strings from registry

Recommended Posts

JohanV

I have software on a lot of computers, which comes with updates regularly.

Before updating, the old software has to be removed.

Normally it wouldn't be a problem, but this software exists from multiple

components, which have to be uninstalled separately.

At this moment I'm uninstalling the old software by using a vbscript,

but this gives me a lots of ugly dosboxes coming and going,

and it makes my (AutoIt) installscript less flexible.

So what I want to do is:

Creating a script that can search the registry,

to be exact in HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

for strings where Publisher is (in my case) Avid Technology.

It has to read the Uninstallstring, change this into a silent uninstall string and then run it.

I think that RegEnumKey and RegEnumVal would come in handy here, but don't know exact how.

Extra information:

The registry entries look like this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1CCE0B0C-C025-4790-80B2-C4AB6062AB36}

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{50280C55-501A-4C2F-BE65-216D7DF99D67}

and so on.

Share this post


Link to post
Share on other sites
JohanV

You can use _RunDOS with regsvr32.exe along with the /s switch to do what you want silently.

I'm sorry, but I don't understand what you mean.

I've found out some things, and came to this code:

$result = _UninstallEntry('Avid', 1)

Func _UninstallEntry($displayname, $value = 0)
    Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    Local $i, $key_main, $key_result, $key_sub, $version, $size = StringLen($displayname)
    Switch $value
        Case 1
            $value = 'UninstallString'
        Case 2
            $value = 'QuietUninstallString'
        Case 3
            $value = 'DisplayVersion'
        Case Else
            $value = ''
    EndSwitch
    For $i = 1 To 1000
        $key_sub = RegEnumKey($key_main, $i)
        If @error Then ExitLoop
        If StringLeft(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $size) = $displayname Then
            $data = RegRead($key_main & '\' & $key_sub, $value)
            If $value = '' Then Return 'Installed'
                msgbox (1, "Found result", 'Msiexec.exe /x' & $key_sub & '/q /le "%LogFile%" REBOOT=ReallySuppress')
            If $data = '' Or @error Then ContinueLoop
            Return $data
        EndIf
    Next
    SetError(1)
    Return
EndFunc

This code gives me the uninstall-string and the possibility to manipulate the string.

Of course I'll replace msgbox to a ShellExecute here, but this is for the test, so I can see what's happening.

With the above code, i'll only get one uninstall-string.

What I want is all uninstall-strings from the publisher 'Avid'

Thanks for your reply

Share this post


Link to post
Share on other sites
JohanV

I think I've found out myself.

My problem was in de first line of the script.

It now looks like this and it works fine for me.

$result = _UninstallEntry('Avid', 2)

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  

×