Jump to content

uninstalling, msiexec using AutoIt


Recommended Posts

hi, i am creating a script for uninstalling a software and then reinstall another version of it.

its msi, how can i uninstall a software in silent mode without restart using autoit?

-

[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"
Link to comment
Share on other sites

  • Moderators

hi, i am creating a script for uninstalling a software and then reinstall another version of it.

its msi, how can i uninstall a software in silent mode without restart using autoit?

-

Check the products site or help file for command line parameters to do so?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This script will give you a two dimensional array. $Array[n][0] = Software name, $Array[n][1] = Silent uninstall

Note: If you don't see any value in $Array[n][1] then there are not silent uninstall for that application and you can follow SmOke_N advise "Check the products site or help file for command line parameters to do so?".

#include <Array.au3>

$ret = _SilentUninstallSoftwareInfo()
_ArrayDisplay($ret, '')

Func _SilentUninstallSoftwareInfo($s_RemoteComputer = '')
    Local $Count = 1
        
    If $s_RemoteComputer <> '' Then $s_RemoteComputer = '\\' & StringReplace($s_RemoteComputer, '\', '') & '\'      
    Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    
    While 1
        $key = RegEnumKey ($regkey, $Count)
        If @error <> 0 then ExitLoop
        $line = RegRead ($regkey & '\' & $key, 'Displayname')
        $line = StringReplace ($line, ' (remove only)', '')
        $SilentUninstall = RegRead($regkey & '\' & $key, 'QuietUninstallString')
        If $SilentUninstall = '' Then 
            $SilentUninstall = RegRead($regkey & '\' & $key, 'UninstallString')
            If StringInStr($SilentUninstall, 'msiexec.exe') = 0 Then
                $SilentUninstall = ''
            Else
                $SilentUninstall = StringReplace($SilentUninstall, '/I', '/X')
            EndIf
        EndIf
        If $line <> '' Then 
            If Not IsDeclared('avArray') Then Dim $avArray[1][2]
            ReDim $avArray[UBound($avArray) + 1][2]         
            $avArray[UBound($avArray) - 1][0] = $line
            $avArray[UBound($avArray) - 1][1] = $SilentUninstall
        EndIf
        $Count = $Count + 1
    WEnd
    $avArray[0][0] = UBound($avArray) - 1
    If Not IsDeclared('avArray') Then
        SetError(1)
        Return('')
    Else
        SetError(0)
        Return($avArray)
    EndIf
EndFunc
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

This script will give you a two dimensional array. $Array[n][0] = Software name, $Array[n][1] = Silent uninstall

Note: If you don't see any value in $Array[n][1] then there are not silent uninstall for that application and you can follow SmOke_N advise "Check the products site or help file for command line parameters to do so?".

#include <Array.au3>

$ret = _SilentUninstallSoftwareInfo()
_ArrayDisplay($ret, '')

Func _SilentUninstallSoftwareInfo($s_RemoteComputer = '')
    Local $Count = 1
        
    If $s_RemoteComputer <> '' Then $s_RemoteComputer = '\\' & StringReplace($s_RemoteComputer, '\', '') & '\'      
    Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    
    While 1
        $key = RegEnumKey ($regkey, $Count)
        If @error <> 0 then ExitLoop
        $line = RegRead ($regkey & '\' & $key, 'Displayname')
        $line = StringReplace ($line, ' (remove only)', '')
        $SilentUninstall = RegRead($regkey & '\' & $key, 'QuietUninstallString')
        If $SilentUninstall = '' Then 
            $SilentUninstall = RegRead($regkey & '\' & $key, 'UninstallString')
            If StringInStr($SilentUninstall, 'msiexec.exe') = 0 Then
                $SilentUninstall = ''
            Else
                $SilentUninstall = StringReplace($SilentUninstall, '/I', '/X')
            EndIf
        EndIf
        If $line <> '' Then 
            If Not IsDeclared('avArray') Then Dim $avArray[1][2]
            ReDim $avArray[UBound($avArray) + 1][2]         
            $avArray[UBound($avArray) - 1][0] = $line
            $avArray[UBound($avArray) - 1][1] = $SilentUninstall
        EndIf
        $Count = $Count + 1
    WEnd
    $avArray[0][0] = UBound($avArray) - 1
    If Not IsDeclared('avArray') Then
        SetError(1)
        Return('')
    Else
        SetError(0)
        Return($avArray)
    EndIf
EndFunc

I just have to say thank you for that gem, that will make a few things easier for me in the future.

"Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend.

Link to comment
Share on other sites

  • 2 months later...

Sorry I'm still new at this scripting thing.

My question is where do i insert the Program.MSI name within you script.

please replay to ejbmail@yahoo.com

This script will give you a two dimensional array. $Array[n][0] = Software name, $Array[n][1] = Silent uninstall

Note: If you don't see any value in $Array[n][1] then there are not silent uninstall for that application and you can follow SmOke_N advise "Check the products site or help file for command line parameters to do so?".

#include <Array.au3>

$ret = _SilentUninstallSoftwareInfo()
_ArrayDisplay($ret, '')

Func _SilentUninstallSoftwareInfo($s_RemoteComputer = '')
    Local $Count = 1
        
    If $s_RemoteComputer <> '' Then $s_RemoteComputer = '\\' & StringReplace($s_RemoteComputer, '\', '') & '\'      
    Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    
    While 1
        $key = RegEnumKey ($regkey, $Count)
        If @error <> 0 then ExitLoop
        $line = RegRead ($regkey & '\' & $key, 'Displayname')
        $line = StringReplace ($line, ' (remove only)', '')
        $SilentUninstall = RegRead($regkey & '\' & $key, 'QuietUninstallString')
        If $SilentUninstall = '' Then 
            $SilentUninstall = RegRead($regkey & '\' & $key, 'UninstallString')
            If StringInStr($SilentUninstall, 'msiexec.exe') = 0 Then
                $SilentUninstall = ''
            Else
                $SilentUninstall = StringReplace($SilentUninstall, '/I', '/X')
            EndIf
        EndIf
        If $line <> '' Then 
            If Not IsDeclared('avArray') Then Dim $avArray[1][2]
            ReDim $avArray[UBound($avArray) + 1][2]         
            $avArray[UBound($avArray) - 1][0] = $line
            $avArray[UBound($avArray) - 1][1] = $SilentUninstall
        EndIf
        $Count = $Count + 1
    WEnd
    $avArray[0][0] = UBound($avArray) - 1
    If Not IsDeclared('avArray') Then
        SetError(1)
        Return('')
    Else
        SetError(0)
        Return($avArray)
    EndIf
EndFunc
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...