Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::Version - 20151110
- ::https://www.reddit.com/user/mrmeme42
- @echo off
- setlocal
- cls
- ::Path to Extracted FF installer
- SET INSTALL=installer\core
- ::Path to 7zip.exe
- SET EXTRACT=files\7zip\7z.exe
- ::Starting Folder
- SET STARTFOLDER=%cd%
- ::FirefoxPortable with CCK
- SET CCKFF=FirefoxPortable\FirefoxPortableESR
- ::FirefoxPortable for testing
- SET TESTFF=FirefoxPortable\FirefoxPortableESR_custom
- ::Path to Firefox installer
- for %%i in (Files\Firefox*.exe) do SET rc=%%i
- ::
- ::User's Name
- SET TNAME="net user %USERNAME% /domain| FIND /I "Full Name""
- FOR /F "tokens=3,4 delims=, " %%A IN ('%TNAME%') DO SET DNAME=%%A %%B
- ::
- goto start&endlocal
- ::
- :varcheck
- cls
- @echo Script Variables Below:
- @echo ........................................................................
- @echo Starting Folder:
- @echo STARTFOLDER = %STARTFOLDER%
- @echo ........................................................................
- @echo Install Folder:
- @echo INSTALL = %INSTALL%
- @echo ........................................................................
- @echo Path to 7zip:
- @echo EXTRACT = %EXTRACT%
- @echo ........................................................................
- @echo Firefox w/CCK:
- @echo CCKFF = %CCKFF%
- @echo ........................................................................
- @echo Firefox test:
- @echo TESTFF = %TESTFF%
- @echo ........................................................................
- @echo User's name:
- @echo DNAME = %DNAME%
- @echo ........................................................................
- pause
- goto start&endlocal
- ::
- :testing
- ::test commands goes here
- cls
- @echo off
- @echo Test commands go here
- pause
- cls
- goto start&endlocal
- :start
- :: WHY ARE YOU LOOKING AT MY NAKED CODE? DO YOU HAVE NO SHAME?!
- cls
- @echo This script will help test custom Firefox settings and create an installer.
- @echo CCK is used to create the customised Firefox settings, use this script to apply and test.
- @echo FirefoxPortable is used to both create and test the customised settings.
- @echo ........................................................................
- ::@echo Running from directory: %STARTFOLDER%
- @echo Custom Firefox creator. Hi %DNAME%, what would you like to do?
- @echo ........................................................................
- @echo 1="Start Firefox w/CCK"
- @echo 2="Start test Firefox"
- @echo 3="Reset & apply changes to test Firefox"
- @echo 4="Update FF version"
- @echo 5="Create customised installer"
- @echo 6="Clear CCK profile folder"
- @echo 7="Readme/Changelog"
- @echo 8="Edit this script"
- @echo 9="Check script variables"
- @echo T="start test command"
- @echo C="Cleanup"
- @echo R="Refresh"
- @echo Q="Quit"
- @echo off
- SET /P ANSWER=Option:
- ::@echo Chosen answer: %ANSWER%
- if /i {%ANSWER%}=={1} (goto :CCKFF)
- if /i {%ANSWER%}=={2} (goto :TESTFF)
- if /i {%ANSWER%}=={3} (goto :reset)
- if /i {%ANSWER%}=={4} (goto :update)
- if /i {%ANSWER%}=={5} (goto :create)
- if /i {%ANSWER%}=={6} (goto :clearcck)
- if /i {%ANSWER%}=={7} (goto :readme)
- if /i {%ANSWER%}=={8} (goto :scriptedit)
- if /i {%ANSWER%}=={9} (goto :varcheck)
- if /i {%ANSWER%}=={t} (goto :testing)
- if /i {%ANSWER%}=={c} (goto :cleanup)
- if /i {%ANSWER%}=={r} (goto :start)
- if /i {%ANSWER%}=={q} (goto :quit)
- goto start&endlocal
- ::
- ::Clean Firefox & Profile
- :reset
- cls
- @echo Resetting Test Firefox
- rmdir /s /q "%TESTFF%\App\Firefox"
- rmdir /s /q "%TESTFF%\Data\profile"
- ::Copy over clean Firefox
- @echo Copying over clean Firefox
- xcopy /Q /E /C /Y /I "%CCKFF%\App\Firefox" "%TESTFF%\App\Firefox"
- ::Clean up Firefox
- @echo Cleaning up Firefox
- del /Q "%TESTFF%\App\Firefox\dictionaries\*.*"
- del /Q "%TESTFF%\App\Firefox\browser\searchplugins\*.*"
- del /Q "%TESTFF%\App\Firefox\maintenanceservice.exe"
- del /Q "%TESTFF%\App\Firefox\maintenanceservice_installer.exe"
- del /Q "%TESTFF%\App\Firefox\updater.exe"
- del /Q "%TESTFF%\App\Firefox\webapp-uninstaller.exe"
- del /Q "%TESTFF%\App\Firefox\crashreporter.exe"
- ::
- if exist "%TESTFF%\App\Firefox\7zip" rmdir /s /q "%TESTFF%\App\Firefox\7zip"
- SET /P ANSWER=Apply Customisations? (Y/N)?
- cls
- ::
- if /i {%ANSWER%}=={y} (goto :apply)
- if /i {%ANSWER%}=={n} (goto :start)
- goto start&endlocal
- ::
- :apply
- @echo Applying customisations
- :: Consolidate all addtional files into CCK profile direcetory
- @echo Consolidating files
- ::Added extensions & search plugins
- xcopy /Q /F /Y "files\Extensions\*.xml" "CCK Profile\firefox\browser\searchplugins\"
- xcopy /Q /E /C /Y /I "Files\Extensions\bundles" "CCK Profile\firefox\distribution\extensions"
- xcopy /Q /F /Y "files\override.ini" "CCK Profile\"
- :: Apply CCK settings
- @echo Adding CCK settings
- xcopy /Q /E /C /Y /I "CCK Profile\firefox" "%TESTFF%\App\Firefox"
- ::
- SET /P ANSWER=Launch test Firefox? (Y/N)?
- ::echo Chosen answer: %ANSWER%
- if /i {%ANSWER%}=={y} (goto :TESTFF)
- if /i {%ANSWER%}=={n} (goto :start)
- goto start&endlocal
- ::
- :: Create Firefox Installer
- :create
- cls
- @echo Ready to create the installer. This may take some time
- pause
- ::Extract files from Firefox installer
- SET rc=
- for %%i in (Files\Firefox*.exe) do SET rc=%%i
- if "%rc%."=="." goto notfound
- SET duplicate=
- for %%i in (Files\Firefox*.exe) do if not "%%i"=="%rc%" SET duplicate=1
- if not %duplicate%.==. goto duplicate
- cls
- ::
- @echo Extracting %rc%
- @echo removing old installer files
- rmdir /s /q "installer"
- mkdir "installer"
- "%EXTRACT%" x "%rc%"
- move /y core "installer"
- move /y setup.exe "installer"
- cls
- @echo extraction complete
- @echo Applying customistations
- rmdir /s /q "%STARTFOLDER%\win32"
- :: Delete unwanted files
- del /q "%INSTALL%\dictionaries\*.*"
- del /q "%INSTALL%\browser\searchplugins\*.*"
- del /q "%INSTALL%\maintenanceservice.exe"
- del /q "%INSTALL%\maintenanceservice_installer.exe"
- del /q "%INSTALL%\updater.exe"
- del /q "%INSTALL%\webapp-uninstaller.exe"
- del /q "%INSTALL%\crashreporter.exe"
- cls
- ::
- ::Add extensions
- ::@echo Adding addtional extensions
- ::if not exist "%INSTALL%\distribution" mkdir "%INSTALL%\distribution"
- ::if not exist "%INSTALL%\distribution\bundles" mkdir "%INSTALL%\distribution\bundles"
- ::xcopy /Q /E /C /Y /I "Files\Extensions\bundles" "%INSTALL%\distribution\bundles\"
- ::Add search engines
- ::@echo Adding addtional search engines
- ::xcopy /Q /F /Y "files\Extensions\*.xml" "%INSTALL%\browser\searchplugins\"
- ::xcopy /Q /F /Y "files\override.ini" "%INSTALL%\"
- ::cls
- ::Add customised settings
- @echo Applying customisations
- rename "CCK Profile\firefox" "core"
- xcopy /Q /E /C /Y /I "CCK Profile\core" "installer\core"
- rename "CCK Profile\core" "firefox"
- cd "installer"
- cls
- :: Creation of custom Firefox Installer
- @echo Creating Installer
- "%STARTFOLDER%\files\7zip\7z.exe" a -r -t7z app.7z -mx -m0=BCJ2 -m1=LZMA:d24 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3
- cls
- cd..
- ::Copy files for setup
- @echo copying files for setup
- xcopy /Q /F /Y "Files\7zSD.sfx" "installer\"
- xcopy /Q /F /Y "Files\*.tag" "installer\"
- ::
- cls
- ::
- cd "installer"
- copy /B 7zSD.sfx+app.tag+app.7z FirefoxESR-custom.exe
- cd..
- rmdir /s /q "installer\core"
- rmdir /s /q "installer\7zip"
- rmdir /s /q "installer\extensions"
- del /q "installer\setup.exe"
- del /q "installer\7zSD.sfx"
- del /q "installer\*.7z"
- del /q "installer\*.tag"
- del /q "installer\*.app"
- cls
- copy /Y "Files\override.ini" "installer\"
- copy /Y "Files\Firefox.bat" "installer\"
- cls
- @echo Custom Firefox Created. Aw Yisss!
- timeout /t 3
- @echo Copying new Installer to deploy folder
- cd %STARTFOLDER%
- cd..
- if exist "%cd%\Deploy Firefox\FirefoxESR-custom.exe" echo f |xcopy /f /y "%cd%\Deploy Firefox\FirefoxESR-custom.exe" "%cd%\Deploy Firefox\FirefoxESR-custom_old.exe"
- if exist "%cd%\Deploy Firefox" echo f |xcopy /f /y "%STARTFOLDER%\Installer\FirefoxESR-custom.exe" "%cd%\Deploy Firefox\FirefoxESR-custom.exe"
- cd %STARTFOLDER%
- @echo all done! : class="re0">)
- timeout /t 3
- goto start&endlocal
- ::
- :notfound
- @echo Error: No Firefox installer found
- timeout /T 5
- goto start&endlocal
- ::
- :duplicate
- @echo Error: More than one Firefox installer found. Remove the unwanted installer(s).
- timeout /T 5
- goto start&endlocal
- ::
- :TESTFF
- start "" "%TESTFF%\FirefoxPortable.exe"
- @echo Starting test Firefox
- timeout /T 3
- goto start&endlocal
- ::
- :CCKFF
- start "" "%CCKFF%\FirefoxPortable.exe"
- @echo Starting Firefox with CCK
- timeout /T 3
- goto start&endlocal
- ::
- ::Open Readme & Changelog
- :readme
- start "%windir%\system32\notepad.exe" "readme.txt"
- goto start&endlocal
- ::
- :scriptedit
- @echo creating backup
- if exist "CustomFirefox_backup2.txt" echo f |xcopy /f /y "CustomFirefox.bat" "CustomFirefox_backup3.txt"
- if exist "CustomFirefox_backup1.txt" echo f |xcopy /f /y "CustomFirefox.bat" "CustomFirefox_backup2.txt"
- echo f |xcopy /f /y "CustomFirefox.bat" "CustomFirefox_backup1.txt"
- start %windir%\system32\notepad.exe "CustomFirefox.bat"
- goto start&endlocal
- ::
- :clearcck
- rmdir /s /q "CCK Profile"
- mkdir "CCK Profile"
- cls
- @echo ........................................................................
- @echo CCK profile is now empty!
- @echo Don't forget to generate and test a new one or bad things will happen :(
- @echo ........................................................................
- pause
- goto start&endlocal
- ::
- :: Update FirefoxPortable with provided installer
- :: Online update with wget also an option.
- :update
- cls
- goto update-off
- ::@echo Offline or Online update
- ::@echo Online updates will download the Firefox installer from Mozilla
- ::SET /P ANSWER=(On/Off)
- ::if /i {%ANSWER%}=={on} (goto :update-on)
- ::if /i {%ANSWER%}=={off} (goto :update-off)
- ::goto start&endlocal
- ::update-on
- ::cd "%startfolder%\files\wget"
- ::cls
- ::wget.exe --no-check-certificate http://www.tpg.com.au/test3.iso
- ::move /y "test3.iso" "%startfolder%\files\".
- ::cd "%startfolder%
- ::goto update-off
- :update-off
- @echo This will update the FirefoxPortable with the installer provided. Continue?
- SET /P ANSWER=(Y/N)
- cls
- if /i {%ANSWER%}=={y} (goto :update-yes)
- if /i {%ANSWER%}=={n} (goto :start)
- goto start&endlocal
- :update-yes
- @echo updating FirefoxPortable version. Please wait
- ::
- SET duplicate=
- for %%i in (Files\Firefox*.exe) do if not "%%i"=="%rc%" SET duplicate=1
- if not %duplicate%.==. goto duplicate
- ::
- if exist "%CCKFF%\App\Firefox_old" if exist "%CCKFF%\App\Firefox" goto ResultTrue
- :ResultTrue
- rmdir /s /q "%CCKFF%\App\Firefox_old"
- xcopy /Q /E /C /Y /I "%CCKFF%\App\Firefox" "%CCKFF%\App\Firefox_old"
- goto blah
- :ResultFalse
- if exist "%CCKFF%\App\Firefox" xcopy /Q /E /C /Y /I "%CCKFF%\App\Firefox" "%CCKFF%\App\Firefox_old"
- goto blah
- :blah
- rmdir /s /q "%CCKFF%\App\Firefox"
- "%EXTRACT%" x "%rc%"
- del /Q "%STARTFOLDER%\setup.exe"
- rmdir /s /q "%STARTFOLDER%\win32"
- rename "%STARTFOLDER%\core" "firefox"
- move /y "%STARTFOLDER%\firefox" "%CCKFF%\App\"
- goto start&endlocal
- ::
- ::Cleanup - Remove any customisations to FFportables & extensions folder
- :cleanup
- cls
- @echo This option doesn't do anything yet. It's a WIP
- @echo ........................................................................
- @echo Clean up any customisations and files
- @echo - FirefoxPortable profiles will be cleared!
- @echo - Extensions stored in "\Files\Extensions" will be cleared!
- @echo - Backups will be deleted (Old FF versions, and scripts)
- @echo - Make sure you have backups!
- @echo ........................................................................
- SET /P ANSWER=Are you sure you want to continue?(Y/N):
- if /i {%ANSWER%}=={y} (goto :cleanup-start)
- if /i {%ANSWER%}=={n} (goto :start)
- goto start&endlocal
- :cleanup-start
- cls
- @echo Running cleanup
- @echo Removing FirefoxPortable profile stores
- :: Commands go here
- @echo Removing Files in "\Files\Extensions"
- :: Commands go here
- @echo Removing Backup files
- :: Commands go here
- @echo Re-installing CCK2 just in case
- :: Commands go here
- @echo Done! Cleanup complete
- @echo ......................
- @echo R="Option Menu"
- @echo Q="Quit"
- SET /P ANSWER=Return to Option menu or Quit?:
- if /i {%ANSWER%}=={r} (goto :start)
- if /i {%ANSWER%}=={q} (goto :quit)
- goto start&endlocal
- ::
- :quit
- endlocal
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement