Seite 1 von 1

how can first uninstall 32-bit version of firefox and then install 64- version of it?

Verfasst: 27 Nov 2017, 18:11
von shirin
Hi,
I have 32-bit version of forefox in my computer. I want to first uninstall 32- version of firefox and then install 64- bit version of it, but I do not know how can I do this, anybody can help me?
these are my scripts:
firefox.ins:

Code: Alles auswählen

[Aktionen]
; common Values for (un)installation
include_insert "common.opsiinc"

ChangeDirectory "%SCRIPTPATH%"
if not(HasMinimumSpace ("%SYSTEMDRIVE%", $MinimumSpace$))
   LogError "Not enough space on %SYSTEMDRIVE%: . "+$MinimumSpace$+" on Drive %SYSTEMDRIVE%: needed for "+$ProductId$+"."
   isFatalError
   ; stop process and set installation status to failed
else
   comment "show product picture"
   ShowBitmap /3 "%scriptpath%\"+"firefox-logo.png" $ProductId$

   if FileExists("%ScriptPath%\delsub.ins")
      comment  "start uninstall sub section"
      sub "%ScriptPath%\delsub.ins"
   endif

   Message "Installing "+$ProductId$+" ..."

   comment "start setup program" 
   Winbatch_install
   sub_check_exitcode
   
   comment "copy files"
   Files_install
   
   comment "test for installation success"
   if not(FileExists($NewExe$))
      logError "Fatal: After Installation "+$NewExe$+" not found"
      isFatalError
   endif

endif

[Winbatch_install]
; something like
"%SCRIPTPATH%\firefox.exe" -ms -ira
 

[Files_install]
; something like
; copy -sv "%SCRIPTPATH%\files\*.*" "%ProgramFiles64Dir%\$ProductId$"
; copy -s "%scriptpath%\extensions\*" "$InstallDir$\extensions\."

[Registry_set_language]
openkey [HKEY_CURRENT_USER\Software\Mozilla Firefox]
set "Lang" = REG_SZ:"$language$"


delfirefox.ins:

Code: Alles auswählen

[Actions]
; common Values for (un)installation
include_insert "common.opsiinc"


comment "show product picture"
ShowBitmap /3 "%scriptpath%\"+$ProductId$+".bmp" $ProductId$

if FileExists("%ScriptPath%\delsub.ins")
   comment  "start uninstall sub section"
   sub "%ScriptPath%\delsub.ins"
endif




delsub.ins:

Code: Alles auswählen



Set $UninstallProgram$ = $InstallDir$ + "\uninstall\helper.exe"
Message "Uninstalling (old) " + $ProductId$ + " ..."



   if FileExists($UninstallProgram$)
      comment "Uninstall program found, starting uninstall"
      Winbatch_uninstall /WaitforProcessending "helper.exe" /Timeoutseconds 10
      sub_check_exitcode
   endif
endif
if (not($InstallDir$ = '')) and (not($InstallDir$ = "not used"))
   Files_uninstall
endif

;-----------------------------------------------------
[Winbatch_uninstall]
"$UninstallProgram$" /S

[Files_uninstall]
del -sf "$InstallDir$\"

[Sub_check_exitcode]
Sub "%ScriptPath%\check_nsis-exitcode.opsiscript"



common.opsiinc:

Code: Alles auswählen

DefVar $TEMP$
DefVar $ProductId$
DefVar $ExeName$
DefVar $MinimumSpace$
DefVar $NewExe$
DefVar $InstallDir$
DefVar $ExitCode$
DefVar $UninstallProgram$


Set $TEMP$ = EnvVar("TEMP")

; ----------------------------------------------------------------
; - Please edit the following values                             -
; ----------------------------------------------------------------
set $ProductId$ = "Mozilla Firefox"
set $ExeName$ = "firefox"
set $MinimumSpace$ = "100 MB"
set $InstallDir$="%ProgramFiles64Dir%\"+$ProductId$
set $NewExe$=$InstallDir$+"\"+$ExeName$+".exe"
; ----------------------------------------------------------------


[sub_check_exitcode]
comment "test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
   comment "looks good: setup program gives exitcode zero"
else
   comment "Setup program gives a exitcode unequal zero: "+$ExitCode$
   if ($ExitCode$ = "1605")
      comment "ERROR_UNKNOWN_PRODUCT   1605   This action is only valid for products that are currently installed."
      comment "Uninstall of a not installed product failed - no problem"
   else
      if ($ExitCode$ = "1641")
         comment "looks good: setup program gives exitcode 1641"
         comment "ERROR_SUCCESS_REBOOT_INITIATED   1641   The installer has initiated a restart. This message is indicative of a success."
      else
         if ($ExitCode$ = "3010")
            comment "looks good: setup program gives exitcode 3010"
            comment "ERROR_SUCCESS_REBOOT_REQUIRED   3010   A restart is required to complete the install. This message is indicative of a success."
         else
            logError "Fatal: Setup program gives an unknown exitcode unequal zero: "+$ExitCode$
            isFatalError
         endif
      endif
   endif
endif

Set $language$ = GetProductProperty("language", "auto")
if ($language$ = "auto")
   set $languagemap$ = GetLocaleInfoMap
   set  $system_language$ = lower(getValue("system_default_language_id", $languagemap$))
   Switch $system_language$
      Case "0407"
         set $language$ = "de"
      EndCase
      Case "0409"
         set $language$ = "en"
      EndCase
      DefaultCase      
         set $language$ = "de"
      EndCase
   EndSwitch
endif

Re: how can first uninstall 32-bit version of firefox and then install 64- version of it?

Verfasst: 28 Nov 2017, 15:30
von mirkt
I didn't want to mess with your code so I have included variables directly into script.. This should work:

delsub.ins

Code: Alles auswählen

DefVar $UninstallerRelativePath$
DefVar $Uninstaller$
DefStringList $ProgramFilesDirs$

Set $UninstallerRelativePath$ = "Mozilla Firefox\uninstall\helper.exe"
Set $ProgramFilesDirs$ = createstringlist("%ProgramFilesSysNativeDir%")

if GetSystemType = "64 Bit System"
   Set $ProgramFilesDirs$ = addtolist($ProgramFilesDirs$, "%ProgramFiles32Dir%")
endif

for %MyProgramFilesDir% in $ProgramFilesDirs$ do sub_try_to_remove

[sub_try_to_remove]
Set $Uninstaller$ = "%MyProgramFilesDir%\" + $UninstallerRelativePath$
if FileExists($Uninstaller1$)
   Winbatch_uninstall_with_helper
   sub_check_exitcode
endif

[Winbatch_uninstall_with_helper]
"$Uninstaller$" -ms

[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
   comment "Looks good: setup program gives exitcode zero"
else
   comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
   if ($ExitCode$ = "1605")
      comment "ERROR_UNKNOWN_PRODUCT   1605   This action is only valid for products that are currently installed."
      comment "Uninstall of a not installed product failed - no problem"
   else
      if ($ExitCode$ = "1641")
         comment "looks good: setup program gives exitcode 1641"
         comment "ERROR_SUCCESS_REBOOT_INITIATED   1641   The installer has initiated a restart. This message is indicative of a success."
      else
         if ($ExitCode$ = "3010")
            comment "looks good: setup program gives exitcode 3010"
            comment "ERROR_SUCCESS_REBOOT_REQUIRED   3010   A restart is required to complete the install. This message is indicative of a success."
         else
            logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
            isFatalError
         endif
      endif
   endif
endif


By the way, I am afraid, your /Timeoutseconds 10 might be not enough..

Re: how can first uninstall 32-bit version of firefox and then install 64- version of it?

Verfasst: 30 Nov 2017, 10:28
von shirin
Thank you for your help mirkt. I tried your script , It can be successfully installed but unfortunately it cannot be uninstalled.
I can see in opsi wrote successfully uninstalled. but when I search for firefox in my computer, I still have firefox.
I donot know why uninstallation scripts donot work :?

Re: how can first uninstall 32-bit version of firefox and then install 64- version of it?

Verfasst: 30 Nov 2017, 11:04
von mirkt
There was a typo

Code: Alles auswählen

DefVar $UninstallerRelativePath$
DefVar $Uninstaller$
DefStringList $ProgramFilesDirs$

Set $UninstallerRelativePath$ = "Mozilla Firefox\uninstall\helper.exe"
Set $ProgramFilesDirs$ = createstringlist("%ProgramFilesSysNativeDir%")

if GetSystemType = "64 Bit System"
   Set $ProgramFilesDirs$ = addtolist($ProgramFilesDirs$, "%ProgramFiles32Dir%")
endif

for %MyProgramFilesDir% in $ProgramFilesDirs$ do sub_try_to_remove

[sub_try_to_remove]
Set $Uninstaller$ = "%MyProgramFilesDir%\" + $UninstallerRelativePath$
if FileExists($Uninstaller$)
   Winbatch_uninstall_with_helper
   sub_check_exitcode
endif

[Winbatch_uninstall_with_helper]
"$Uninstaller$" -ms

[Sub_check_exitcode]
comment "Test for installation success via exit code"
set $ExitCode$ = getLastExitCode
; informations to exit codes see
; http://msdn.microsoft.com/en-us/library/aa372835(VS.85).aspx
; http://msdn.microsoft.com/en-us/library/aa368542.aspx
if ($ExitCode$ = "0")
   comment "Looks good: setup program gives exitcode zero"
else
   comment "Setup program gives a exitcode unequal zero: " + $ExitCode$
   if ($ExitCode$ = "1605")
      comment "ERROR_UNKNOWN_PRODUCT   1605   This action is only valid for products that are currently installed."
      comment "Uninstall of a not installed product failed - no problem"
   else
      if ($ExitCode$ = "1641")
         comment "looks good: setup program gives exitcode 1641"
         comment "ERROR_SUCCESS_REBOOT_INITIATED   1641   The installer has initiated a restart. This message is indicative of a success."
      else
         if ($ExitCode$ = "3010")
            comment "looks good: setup program gives exitcode 3010"
            comment "ERROR_SUCCESS_REBOOT_REQUIRED   3010   A restart is required to complete the install. This message is indicative of a success."
         else
            logError "Fatal: Setup program gives an unknown exitcode unequal zero: " + $ExitCode$
            isFatalError
         endif
      endif
   endif
endif

Re: how can first uninstall 32-bit version of firefox and then install 64- version of it?

Verfasst: 30 Nov 2017, 11:14
von shirin
No actually I corrected it before running the scripts. the problem is not related to typing mistakes. :(