Advertisement
sjlogin

FF profile tester

Sep 20th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 11.83 KB | None | 0 0
  1. ::Version - 20151110
  2. ::https://www.reddit.com/user/mrmeme42
  3. @echo off
  4. setlocal
  5. cls
  6. ::Path to Extracted FF installer
  7. SET INSTALL=installer\core
  8. ::Path to 7zip.exe
  9. SET EXTRACT=files\7zip\7z.exe
  10. ::Starting Folder
  11. SET STARTFOLDER=%cd%
  12. ::FirefoxPortable with CCK
  13. SET CCKFF=FirefoxPortable\FirefoxPortableESR
  14. ::FirefoxPortable for testing
  15. SET TESTFF=FirefoxPortable\FirefoxPortableESR_custom
  16. ::Path to Firefox installer
  17. for %%i in (Files\Firefox*.exe) do SET rc=%%i
  18. ::
  19. ::User's Name
  20. SET TNAME="net user %USERNAME% /domain| FIND /I "Full Name""
  21. FOR /F "tokens=3,4 delims=, " %%A IN ('%TNAME%') DO SET DNAME=%%A %%B
  22. ::
  23. goto start&endlocal
  24. ::
  25. :varcheck
  26. cls
  27. @echo Script Variables Below:
  28. @echo ........................................................................
  29. @echo Starting Folder: 
  30. @echo STARTFOLDER = %STARTFOLDER%
  31. @echo ........................................................................
  32. @echo Install Folder:
  33. @echo INSTALL = %INSTALL%
  34. @echo ........................................................................
  35. @echo Path to 7zip:
  36. @echo EXTRACT = %EXTRACT%
  37. @echo ........................................................................
  38. @echo Firefox w/CCK:
  39. @echo CCKFF = %CCKFF%
  40. @echo ........................................................................
  41. @echo Firefox test:
  42. @echo TESTFF = %TESTFF%
  43. @echo ........................................................................
  44. @echo User's name:
  45. @echo DNAME = %DNAME%
  46. @echo ........................................................................
  47. pause
  48. goto start&endlocal
  49. ::
  50. :testing
  51. ::test commands goes here
  52. cls
  53. @echo off
  54. @echo Test commands go here
  55. pause
  56. cls
  57. goto start&endlocal
  58. :start
  59. :: WHY ARE YOU LOOKING AT MY NAKED CODE? DO YOU HAVE NO SHAME?!
  60. cls
  61. @echo This script will help test custom Firefox settings and create an installer.
  62. @echo CCK is used to create the customised Firefox settings, use this script to apply and test.
  63. @echo FirefoxPortable is used to both create and test the customised settings.
  64. @echo ........................................................................
  65. ::@echo Running from directory: %STARTFOLDER%
  66. @echo Custom Firefox creator. Hi %DNAME%, what would you like to do?
  67. @echo ........................................................................
  68. @echo 1="Start Firefox w/CCK"
  69. @echo 2="Start test Firefox"
  70. @echo 3="Reset & apply changes to test Firefox"
  71. @echo 4="Update FF version"
  72. @echo 5="Create customised installer"  
  73. @echo 6="Clear CCK profile folder"
  74. @echo 7="Readme/Changelog"
  75. @echo 8="Edit this script"     
  76. @echo 9="Check script variables"
  77. @echo T="start test command"
  78. @echo C="Cleanup"
  79. @echo R="Refresh"
  80. @echo Q="Quit"
  81. @echo off
  82. SET /P ANSWER=Option:
  83. ::@echo Chosen answer: %ANSWER%
  84. if /i {%ANSWER%}=={1} (goto :CCKFF)
  85. if /i {%ANSWER%}=={2} (goto :TESTFF)
  86. if /i {%ANSWER%}=={3} (goto :reset)
  87. if /i {%ANSWER%}=={4} (goto :update)
  88. if /i {%ANSWER%}=={5} (goto :create)
  89. if /i {%ANSWER%}=={6} (goto :clearcck)
  90. if /i {%ANSWER%}=={7} (goto :readme)
  91. if /i {%ANSWER%}=={8} (goto :scriptedit)
  92. if /i {%ANSWER%}=={9} (goto :varcheck)
  93. if /i {%ANSWER%}=={t} (goto :testing)
  94. if /i {%ANSWER%}=={c} (goto :cleanup)
  95. if /i {%ANSWER%}=={r} (goto :start)
  96. if /i {%ANSWER%}=={q} (goto :quit)
  97. goto start&endlocal
  98. ::
  99. ::Clean Firefox & Profile
  100. :reset
  101. cls
  102. @echo Resetting Test Firefox
  103. rmdir /s /q "%TESTFF%\App\Firefox"
  104. rmdir /s /q "%TESTFF%\Data\profile"
  105. ::Copy over clean Firefox
  106. @echo Copying over clean Firefox
  107. xcopy /Q /E /C /Y /I "%CCKFF%\App\Firefox" "%TESTFF%\App\Firefox"
  108. ::Clean up Firefox
  109. @echo Cleaning up Firefox
  110. del /Q "%TESTFF%\App\Firefox\dictionaries\*.*"
  111. del /Q "%TESTFF%\App\Firefox\browser\searchplugins\*.*"
  112. del /Q "%TESTFF%\App\Firefox\maintenanceservice.exe"
  113. del /Q "%TESTFF%\App\Firefox\maintenanceservice_installer.exe"
  114. del /Q "%TESTFF%\App\Firefox\updater.exe"
  115. del /Q "%TESTFF%\App\Firefox\webapp-uninstaller.exe"
  116. del /Q "%TESTFF%\App\Firefox\crashreporter.exe"
  117. ::
  118. if exist "%TESTFF%\App\Firefox\7zip" rmdir /s /q "%TESTFF%\App\Firefox\7zip"
  119. SET /P ANSWER=Apply Customisations? (Y/N)?
  120. cls
  121. ::
  122. if /i {%ANSWER%}=={y} (goto :apply)
  123. if /i {%ANSWER%}=={n} (goto :start)
  124. goto start&endlocal
  125. ::
  126. :apply
  127. @echo Applying customisations
  128. :: Consolidate all addtional files into CCK profile direcetory
  129. @echo Consolidating files
  130. ::Added extensions & search plugins
  131. xcopy /Q /F /Y "files\Extensions\*.xml" "CCK Profile\firefox\browser\searchplugins\"
  132. xcopy /Q /E /C /Y /I "Files\Extensions\bundles" "CCK Profile\firefox\distribution\extensions"
  133. xcopy /Q /F /Y "files\override.ini" "CCK Profile\"
  134. :: Apply CCK settings
  135. @echo Adding CCK settings
  136. xcopy /Q /E /C /Y /I "CCK Profile\firefox" "%TESTFF%\App\Firefox"
  137. ::
  138. SET /P ANSWER=Launch test Firefox? (Y/N)?
  139. ::echo Chosen answer: %ANSWER%
  140. if /i {%ANSWER%}=={y} (goto :TESTFF)
  141. if /i {%ANSWER%}=={n} (goto :start)
  142. goto start&endlocal
  143. ::
  144. :: Create Firefox Installer
  145. :create
  146. cls
  147. @echo Ready to create the installer. This may take some time
  148. pause
  149. ::Extract files from Firefox installer
  150. SET rc=
  151. for %%i in (Files\Firefox*.exe) do SET rc=%%i
  152. if "%rc%."=="." goto notfound
  153. SET duplicate=
  154. for %%i in (Files\Firefox*.exe) do if not "%%i"=="%rc%" SET duplicate=1
  155. if not %duplicate%.==. goto duplicate
  156. cls
  157. ::
  158. @echo Extracting %rc%
  159. @echo removing old installer files
  160. rmdir /s /q "installer"
  161. mkdir "installer"
  162. "%EXTRACT%" x "%rc%"
  163. move /y core "installer"
  164. move /y setup.exe "installer"
  165. cls
  166. @echo extraction complete
  167. @echo Applying customistations
  168. rmdir /s /q "%STARTFOLDER%\win32"
  169. :: Delete unwanted files
  170. del /q "%INSTALL%\dictionaries\*.*"
  171. del /q "%INSTALL%\browser\searchplugins\*.*"
  172. del /q "%INSTALL%\maintenanceservice.exe"
  173. del /q "%INSTALL%\maintenanceservice_installer.exe"
  174. del /q "%INSTALL%\updater.exe"
  175. del /q "%INSTALL%\webapp-uninstaller.exe"
  176. del /q "%INSTALL%\crashreporter.exe"
  177. cls
  178. ::
  179. ::Add extensions
  180. ::@echo Adding addtional extensions
  181. ::if not exist "%INSTALL%\distribution" mkdir "%INSTALL%\distribution"
  182. ::if not exist "%INSTALL%\distribution\bundles" mkdir "%INSTALL%\distribution\bundles"
  183. ::xcopy /Q /E /C /Y /I "Files\Extensions\bundles" "%INSTALL%\distribution\bundles\"
  184. ::Add search engines
  185. ::@echo Adding addtional search engines
  186. ::xcopy /Q /F /Y "files\Extensions\*.xml" "%INSTALL%\browser\searchplugins\"
  187. ::xcopy /Q /F /Y "files\override.ini" "%INSTALL%\"
  188. ::cls
  189. ::Add customised settings
  190. @echo Applying customisations
  191. rename "CCK Profile\firefox" "core"
  192. xcopy /Q /E /C /Y /I "CCK Profile\core" "installer\core"
  193. rename "CCK Profile\core" "firefox"
  194. cd "installer"
  195. cls
  196. :: Creation of custom Firefox Installer
  197. @echo Creating Installer
  198. "%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
  199. cls
  200. cd..
  201. ::Copy files for setup
  202. @echo copying files for setup
  203. xcopy /Q /F /Y "Files\7zSD.sfx" "installer\"
  204. xcopy /Q /F /Y "Files\*.tag" "installer\"
  205. ::
  206. cls
  207. ::
  208. cd "installer"
  209. copy /B 7zSD.sfx+app.tag+app.7z FirefoxESR-custom.exe
  210. cd..
  211. rmdir /s /q "installer\core"
  212. rmdir /s /q "installer\7zip"
  213. rmdir /s /q "installer\extensions"
  214. del /q "installer\setup.exe"
  215. del /q "installer\7zSD.sfx"
  216. del /q "installer\*.7z"
  217. del /q "installer\*.tag"
  218. del /q "installer\*.app"
  219. cls
  220. copy /Y "Files\override.ini" "installer\"
  221. copy /Y "Files\Firefox.bat" "installer\"
  222. cls
  223. @echo Custom Firefox Created. Aw Yisss!
  224. timeout /t 3
  225. @echo Copying new Installer to deploy folder
  226. cd %STARTFOLDER%
  227. cd..
  228. 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"
  229. if exist "%cd%\Deploy Firefox" echo f |xcopy /f /y "%STARTFOLDER%\Installer\FirefoxESR-custom.exe" "%cd%\Deploy Firefox\FirefoxESR-custom.exe"
  230. cd %STARTFOLDER%
  231. @echo all done! : class="re0">)
  232. timeout /t 3
  233. goto start&endlocal
  234. ::
  235. :notfound
  236. @echo Error: No Firefox installer found
  237. timeout /T 5
  238. goto start&endlocal
  239. ::
  240. :duplicate
  241. @echo Error: More than one Firefox installer found. Remove the unwanted installer(s).
  242. timeout /T 5
  243. goto start&endlocal
  244. ::
  245. :TESTFF
  246. start "" "%TESTFF%\FirefoxPortable.exe"
  247. @echo Starting test Firefox
  248. timeout /T 3
  249. goto start&endlocal
  250. ::
  251. :CCKFF
  252. start "" "%CCKFF%\FirefoxPortable.exe"
  253. @echo Starting Firefox with CCK
  254. timeout /T 3
  255. goto start&endlocal
  256. ::
  257. ::Open Readme & Changelog
  258. :readme
  259. start "%windir%\system32\notepad.exe" "readme.txt"
  260. goto start&endlocal
  261. ::
  262. :scriptedit
  263. @echo creating backup
  264. if exist "CustomFirefox_backup2.txt" echo f |xcopy /f /y "CustomFirefox.bat" "CustomFirefox_backup3.txt"
  265. if exist "CustomFirefox_backup1.txt" echo f |xcopy /f /y "CustomFirefox.bat" "CustomFirefox_backup2.txt"
  266. echo f |xcopy /f /y "CustomFirefox.bat" "CustomFirefox_backup1.txt"
  267. start %windir%\system32\notepad.exe "CustomFirefox.bat"
  268. goto start&endlocal
  269. ::
  270. :clearcck
  271. rmdir /s /q "CCK Profile"
  272. mkdir "CCK Profile"
  273. cls
  274. @echo ........................................................................
  275. @echo CCK profile is now empty!
  276. @echo Don't forget to generate and test a new one or bad things will happen :(
  277. @echo ........................................................................
  278. pause
  279. goto start&endlocal
  280. ::
  281. :: Update FirefoxPortable with provided installer
  282. :: Online update with wget also an option.
  283. :update
  284. cls
  285. goto update-off
  286. ::@echo Offline or Online update
  287. ::@echo Online updates will download the Firefox installer from Mozilla
  288. ::SET /P ANSWER=(On/Off)
  289. ::if /i {%ANSWER%}=={on} (goto :update-on)
  290. ::if /i {%ANSWER%}=={off} (goto :update-off)
  291. ::goto start&endlocal
  292. ::update-on
  293. ::cd "%startfolder%\files\wget"
  294. ::cls
  295. ::wget.exe --no-check-certificate http://www.tpg.com.au/test3.iso
  296. ::move /y "test3.iso" "%startfolder%\files\".
  297. ::cd "%startfolder%
  298. ::goto update-off
  299. :update-off
  300. @echo This will update the FirefoxPortable with the installer provided. Continue?
  301. SET /P ANSWER=(Y/N)
  302. cls
  303. if /i {%ANSWER%}=={y} (goto :update-yes)
  304. if /i {%ANSWER%}=={n} (goto :start)
  305. goto start&endlocal
  306. :update-yes
  307. @echo updating FirefoxPortable version. Please wait
  308. ::
  309. SET duplicate=
  310. for %%i in (Files\Firefox*.exe) do if not "%%i"=="%rc%" SET duplicate=1
  311. if not %duplicate%.==. goto duplicate
  312. ::
  313. if exist "%CCKFF%\App\Firefox_old" if exist "%CCKFF%\App\Firefox" goto ResultTrue
  314. :ResultTrue
  315. rmdir /s /q "%CCKFF%\App\Firefox_old"
  316. xcopy /Q /E /C /Y /I "%CCKFF%\App\Firefox" "%CCKFF%\App\Firefox_old"
  317. goto blah
  318. :ResultFalse
  319. if exist "%CCKFF%\App\Firefox" xcopy /Q /E /C /Y /I "%CCKFF%\App\Firefox" "%CCKFF%\App\Firefox_old"
  320. goto blah
  321. :blah
  322. rmdir /s /q "%CCKFF%\App\Firefox"
  323. "%EXTRACT%" x "%rc%"
  324. del /Q "%STARTFOLDER%\setup.exe"
  325. rmdir /s /q "%STARTFOLDER%\win32"
  326. rename "%STARTFOLDER%\core" "firefox"
  327. move /y "%STARTFOLDER%\firefox" "%CCKFF%\App\"
  328. goto start&endlocal
  329. ::
  330. ::Cleanup - Remove any customisations to FFportables & extensions folder
  331. :cleanup
  332. cls
  333. @echo This option doesn't do anything yet. It's a WIP
  334. @echo ........................................................................
  335. @echo Clean up any customisations and files
  336. @echo - FirefoxPortable profiles will be cleared!
  337. @echo - Extensions stored in "\Files\Extensions" will be cleared!
  338. @echo - Backups will be deleted (Old FF versions, and scripts)
  339. @echo - Make sure you have backups!
  340. @echo ........................................................................
  341. SET /P ANSWER=Are you sure you want to continue?(Y/N):
  342. if /i {%ANSWER%}=={y} (goto :cleanup-start)
  343. if /i {%ANSWER%}=={n} (goto :start)
  344. goto start&endlocal
  345. :cleanup-start
  346. cls
  347. @echo Running cleanup
  348. @echo Removing FirefoxPortable profile stores
  349. :: Commands go here
  350. @echo Removing Files in "\Files\Extensions"
  351. :: Commands go here
  352. @echo Removing Backup files
  353. :: Commands go here
  354. @echo Re-installing CCK2 just in case
  355. :: Commands go here
  356. @echo Done! Cleanup complete
  357. @echo ......................
  358. @echo R="Option Menu"
  359. @echo Q="Quit"
  360. SET /P ANSWER=Return to Option menu or Quit?:
  361. if /i {%ANSWER%}=={r} (goto :start)
  362. if /i {%ANSWER%}=={q} (goto :quit)
  363. goto start&endlocal
  364. ::
  365. :quit
  366. endlocal
  367. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement