2 Replies Latest reply on Jul 11, 2018 2:54 AM by SitzRieSe

    Remove software, and then re-install after reboot

    JHammo Apprentice

      Is there a way in escript to do an action, and then flag to run another action after a restart?  for example I'm looking at uninstalling a product, and then re-installing the product after a restart.  This is needed for a specific product where I need to do a repair, but the only option is to remove and the re-install.

       

      thanks all for your help.


      Jason Hammond

        • 1. Re: Remove software, and then re-install after reboot
          _Mel_ Master

          you can simply uncheck the property that says that reinstall / repair is supported - then reinstall / repair will be replaced by uninstall + install.

          then do a reboot at the end of the uninstallation and you are done.

          1 of 1 people found this helpful
          • 2. Re: Remove software, and then re-install after reboot
            SitzRieSe Expert

            Here is another possible way which is more universal, but you have to put it inside of the script:

             

            !==============================================

            !Uninstall any old version if no upgrade possible

            !

            Set('DisplayNameValue','0')

            Set('UninstallParameter','0')

            Set('exitcode','0')

            Set('RegPathResult','')

            Set('RegistryValue','DisplayName')

            Set('RegistryPath','HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall')

            !

            !=== Enable for x64 application

            !CallScript('.\Extern$\RegSearch.ps1','')/x64/TS

            !RegReadValueEx('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%RegPathResult%','UninstallString','Uninstall',reUseX64Hive)

            !If not %Uninstall%=''

            ! ExecuteEx('%Uninstall% %UninstallParameter%','exitcode','120')/?/TS

            ! If not %exitcode%='0'

            !  If not %exitcode%='3010'

            !   ExitProcEx(Failed,'The Uninstallation of pre installed version failed with %exitcode%')

            !=== Enable for x86 application

            !CallScript('.\Extern$\RegSearch.ps1','')/TS

            !RegReadValueEx('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%RegPathResult%','UninstallString','Uninstall',)

            !If not %Uninstall%=''

            ! ExecuteEx('%Uninstall% %UninstallParameter%','exitcode','120')/?/TS

            ! If not %exitcode%='0'

            !  If not %exitcode%='3010'

            !   ExitProcEx(Failed,'The Uninstallation of pre installed version failed with %exitcode%')

            !  

            !==============================================

            !MSI Installer

            !=== Enable for x64 application

            !CallScript('.\Extern$\RegSearch.ps1','')/x64/TS

            !If not %Uninstall%=''

            ! ExecuteEx('Msiexec /X%RegPathResult% /quiet','exitcode','120')/?/TS

            ! If not %exitcode%='0'

            !  If not %exitcode%='3010'

            !   ExitProcEx(Failed,'The Uninstallation of pre installed failed with %exitcode%')

            !=== Enable for x86 application

            !CallScript('.\Extern$\RegSearch.ps1','')/TS

            !If not %Uninstall%=''

            ! ExecuteEx('Msiexec /X%RegPathResult% /quiet','exitcode','120')/?/TS

            ! If not %exitcode%='0'

            !  If not %exitcode%='3010'

            !   ExitProcEx(Failed,'The Uninstallation of pre installed failed with %exitcode%')

            !==============================================

            !Wise Installer

            !=== Enable for x64 application

            !CallScript('.\Extern$\RegSearch.ps1','')/x64/TS

            !RegReadValueEx('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%RegPathResult%','QuietUninstallString','Uninstall',reUseX64Hive)

            !If not %Uninstall%=''

            ! ExecuteEx('%Uninstall%','exitcode','120')/?/TS

            ! If not %exitcode%='0'

            !  If not %exitcode%='3010'

            !   ExitProcEx(Failed,'The Uninstallation of pre installed version failed with %exitcode%')

            !=== Enable for x86 application

            !CallScript('.\Extern$\RegSearch.ps1','')/TS

            !RegReadValueEx('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%RegPathResult%','QuietUninstallString','Uninstall',)

            !If not %Uninstall%=''

            ! ExecuteEx('%Uninstall%','exitcode','120')/?/TS

            ! If not %exitcode%='0'

            !  If not %exitcode%='3010'

            !   ExitProcEx(Failed,'The Uninstallation of pre installed version failed with %exitcode%')

            !

            !==============================================

             

            You have to put the RegSearch.ps1 inside of the Extern$ folder.

             

            # In der Registry nach einer Variable und dem entsprechenden Inhalt suchen.

            # zu suchende Variable

            $searchForName  = Get-NiVar "RegistryValue"

             

            # zu suchender Wert

            $searchforValue = Get-NiVar "DisplayNameValue"

             

            # zu durchsuchender Pfad

            $searchforPath = Get-NiVar "RegistryPath"

             

            $return = (Get-ChildItem $searchforPath | Get-ItemProperty | where {$_.$searchForName -match $searchForValue } | select -last 1)

            if($return) {

                $return = $return.PSChildName

                if($return) {

                    Set-NiVar "RegPathResult" $return

                }

            }

             

            You have to fill in the DisplaynameValue and enable the part for the correct installer. After that the script will search for the software and uninstall any found version.

             

            regards

             

            Alex