locked
Firefox installation script problem RRS feed

  • Question

  • Hi,

    I'm struggling with what should be a very simple script to install Firefox and remove an older version. 

    Steps it should take in order:

    1) Install a newer version of Firefox

    2) Copy some customization files

    3) Check if an older version is installed, uninstall if yes and do some cleanup afterwards

    This is my script currently:

    "%~dp0Firefox Setup 60.1.0esr_x64_GER /INI=%~dp0setup.ini" -ms
    xcopy /s /y "%~dp0Customize\*" "%ProgramFiles%\Mozilla Firefox\*"
    if exists "%ProgramFiles(x86)%\Mozilla Firefox" goto cleanup
    
    :cleanup
    "%ProgramFiles(x86)%\Mozilla Firefox\Uninstall\helper.exe /S"
    del /s /q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Firefox KMB.lnk"
    del /s /q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk"
    rmdir /s /q "C\Program Files (x86)\Mozilla Firefox"
    reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\mozilla.org"
    reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla"

    I'm ashamed to admit, but the only thing that seems to work is xcopy...

    Here's the output from the log file:

    C:\Users\xxx\Desktop\blablabla>"C:\Users\WA0106_I\Desktop\blablabla\Firefox Setup 60.1.0esr_x64_GER /INI=C:\Users\xxx\Desktop\blablabla\setup.ini" -ms 
    Die Syntax fr den Dateinamen, Verzeichnisnamen oder die Datentr„gerbezeichnung ist falsch.
    
    C:\Users\xxx\Desktop\blablabla>xcopy /s /y "C:\Users\xxx\Desktop\blablabla\Customize\*" "C:\Program Files\Mozilla Firefox\*" 
    C:\Users\xxx\Desktop\blablabla\Customize\cck2.cfg
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\chrome.manifest
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\bundles\disablesafemode\chrome.manifest
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\bundles\disablesafemode\chrome\content\safeMode.xul
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CAPSCheckLoadURIFramescript.js
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CAPSClipboardFramescript.js
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2AboutAddonsOverlay.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2AboutDialogOverlay.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2AboutHomeFramescript.js
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2AboutSupportOverlay.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2BrowserOverlay.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2FileBlock.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2Framescript.js
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CCK2PreferencesOverlay.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\CTPPermissions.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\Preferences.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\Timer.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\cck2\modules\Utils.jsm
    C:\Users\xxx\Desktop\blablabla\Customize\defaults\pref\autoconfig.js
    20 Datei(en) kopiert
    ""C:\Program Files (x86)\Mozilla Firefox"" kann syntaktisch an dieser Stelle nicht verarbeitet werden.
    
    C:\Users\xxx\Desktop\blablabla>if exists "C:\Program Files (x86)\Mozilla Firefox" goto cleanup


    Unfortunately the messages are in German.

    First error: The syntax for filename, directory name, or volume label is incorrect.

    Second error: can not be processed syntactically at this point.

    Even something like this throws an error:

    c:\>if exists c:\Variables.json echo Exiting && Exit
    "c:\Variables.json" kann syntaktisch an dieser Stelle nicht verarbeitet werden.

    Any advise?

    Kind regards,

    Wojciech

    Tuesday, August 21, 2018 9:41 AM

Answers

  • ... didn't pay attention before but the syntax is if exist  (not if exists ... without the s in the end!)

    (Changed the code in my first answer as well)


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, August 21, 2018 11:20 AM
    • Marked as answer by rozanw Tuesday, August 21, 2018 1:37 PM
    Tuesday, August 21, 2018 11:13 AM

All replies

  • You should not use cmd/batch anymore. Use Powershell instead. It's much more feature rich and easier to learn. And there is a German Powershell forum as well -> https://social.technet.microsoft.com/Forums/de-de/home?forum=powershell_de.

    If you incist to use batch/cmd you should start with somethng like that:

    "%~dp0Firefox Setup 60.1.0esr_x64_GER" /INI="%~dp0setup.ini" -ms
    xcopy /s /y "%~dp0Customize\*" "%ProgramFiles%\Mozilla Firefox\*"
    if exist "%ProgramFiles(x86)%\Mozilla Firefox" goto cleanup
    
    :cleanup
    "%ProgramFiles(x86)%\Mozilla Firefox\Uninstall\helper.exe" /S
    del /s /q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Firefox KMB.lnk"
    del /s /q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Mozilla Firefox.lnk"
    rmdir /s /q "C\Program Files (x86)\Mozilla Firefox"
    reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\mozilla.org"
    reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, August 21, 2018 11:20 AM
    Tuesday, August 21, 2018 9:55 AM
    1. Hi.....
    2. Install the YesScript extension and restart FirefoxJavaScript Toggle On and Off extension.
    3. Click the menu button and choose Add-ons. ...
    4. In the Add-ons Manager tab, select the Extensions panel.
    5. Find the JavaScript Toggle On and Off entry and click the Preferences button.
    Tuesday, August 21, 2018 10:04 AM
  • Hi,

    Thanks for your tip. One error down, one to go. 

    I can now install Firefox, but the IF EXISTS line is still throwing an error

    ""C:\Program Files (x86)\Mozilla Firefox"" kann syntaktisch an dieser Stelle nicht verarbeitet werden.

    I'm curious about the double ". Is this normal?

    Kind regards,

    Wojciech

    Tuesday, August 21, 2018 10:59 AM
  • ... didn't pay attention before but the syntax is if exist  (not if exists ... without the s in the end!)

    (Changed the code in my first answer as well)


    Best regards,

    (79,108,97,102|%{[char]$_})-join''


    • Edited by BOfH-666 Tuesday, August 21, 2018 11:20 AM
    • Marked as answer by rozanw Tuesday, August 21, 2018 1:37 PM
    Tuesday, August 21, 2018 11:13 AM
  • I knew it was simple...

    Thanks:)

    Tuesday, August 21, 2018 1:37 PM
  • As an aside, this solution is not going to be robust because Firefox might be installed somewhere else (e.g., per-user install).

    -- Bill Stewart [Bill_Stewart]

    Tuesday, August 21, 2018 1:43 PM
  • ... because Firefox might be installed somewhere else (e.g., per-user install).
    ... or in 64 bit ...  ;-)

    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, August 21, 2018 1:44 PM