Computer Hope

Microsoft => Microsoft DOS => Topic started by: jstyles on February 15, 2017, 09:10:30 AM

Title: Batch file help
Post by: jstyles on February 15, 2017, 09:10:30 AM
Hello, I am trying to have this batch file determine if the OS is 32/64 bit and if firefox is currently installed to run the update. However, the way I have it setup right now it installs both 32/64 bit versions and I only want it to run if that particular platform installation currently exists. So, I know my issue is with the "IF" statement chaining and maybe its only doing one of the checks instead of combining the two. Not sure how to go about it at this point and I am open to suggestions. Below is my code:

@echo off
setlocal
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS=32BIT || set OS=64BIT
REM=========================================================================
REM Deploy Firefox
REM=========================================================================
REM Date: 13 February 2017
REM Author: SCCM TEAM
REM
REM Script Details:
REM ---------------
REM    This script will update Firefox if previously installed:
REM         + Silently install or upgrade Firefox
REM         + Disables the 'Automatically check for updates' option
REM         + Disables the 'Always check to see if Firefox is the default browser on start-up' option
REM         + Works for Windows 7 x86 and x64
REM
REM=========================================================================

REM Removes Mozilla Maintenance Service
taskkill /F /IM maintenanceservice.exe
"C:\Program Files (x86)\Mozilla Maintenance Service\uninstall.exe" /S
"C:\Program Files\Mozilla Maintenance Service\uninstall.exe" /S

REM Install Firefox 51.0.1 without Mozilla Maintenance Service
if %OS%==32BIT (
   if exist "%programfiles%\Mozilla Firefox\firefox.exe" (
      START "" /wait "%~dp0Firefox Setup 51.0.1.exe" /INI="%~dp0Install.ini"
   )
)   
if %OS%==64BIT (
   if exist "%ProgramFiles(x86)%\Mozilla Firefox\firefox.exe" (
      START "" /wait "%~dp0Firefox Setup 51.0.1.exe" /INI="%~dp0Install.ini"
   )   
)
if %OS%==64BIT (
   if exist "%programfiles%\Mozilla Firefox\firefox.exe" (
      START "" /wait "%~dp0Firefox Setup 51.0.1_x64.exe" /INI="%~dp0Install.ini"
   )
)   

REM Install 32-bit customisations
if exist "%programfiles%\Mozilla Firefox\" copy /Y "%~dp0mozilla.cfg" "%programfiles%\Mozilla Firefox\"
if exist "%programfiles%\Mozilla Firefox\" copy /Y "%~dp0local-settings.js" "%programfiles%\Mozilla Firefox\defaults\pref"

REM Install 64-bit customisations
if exist "%ProgramFiles(x86)%\Mozilla Firefox\" copy /Y "%~dp0mozilla.cfg" "%ProgramFiles(x86)%\Mozilla Firefox\"
if exist "%ProgramFiles(x86)%\Mozilla Firefox\" copy /Y "%~dp0local-settings.js" "%ProgramFiles(x86)%\Mozilla Firefox\defaults\pref"

REM Removes Firefox Desktop Icon - Windows 7
if exist "%public%\Desktop\Mozilla Firefox.lnk" del "%public%\Desktop\Mozilla Firefox.lnk"

sc config MozillaMaintenance start= disabled

REM Return exit code to SCCM
exit /B %EXIT_CODE%
Title: Re: Batch file help
Post by: patio on February 15, 2017, 10:52:34 AM
I believe FireFox install includes both....so the batch would be redundant...
Title: Re: Batch file help
Post by: Allan on February 15, 2017, 11:10:30 AM
Actually no - separate 32bit & 64 bit downloads
Title: Re: Batch file help
Post by: patio on February 15, 2017, 11:19:45 AM
Thanx