@echo off echo ************************************** echo * Portable Firefox Live Launcher 0.1 * echo ************************************** echo. rem Default values SET FirefoxStartDir="%~dp0" SET FirefoxTempDir= SET JUMP_BACK_TO= rem Evaluate Passed Parameters IF /i "%~1"=="/?" goto HOW_TO_USE IF /i "%~1"=="-?" goto HOW_TO_USE IF /i "%~1"=="-h" goto HOW_TO_USE IF /i "%~1"=="--h" goto HOW_TO_USE IF NOT "%~1"=="" goto WITH_PARAM IF "%~1"=="" goto TEMP rem Parameter passed in :WITH_PARAM SET FirefoxTempDir=%~1 SET JUMP_BACK_TO=TEMP goto PREPARE_PATH rem Determine Temp Directory (Check TEMP variable) :TEMP IF "%TEMP%"=="" ( goto TMP ) SET FirefoxTempDir=%TEMP% SET JUMP_BACK_TO=TMP goto PREPARE_PATH rem Determine Temp Directory (Check TMP Variable) :TMP IF "%TMP%"=="" ( goto LW_D ) SET FirefoxTempDir=%TMP% SET JUMP_BACK_TO=LW_D goto PREPARE_PATH rem Try D: drive for temp... :LW_D SET FirefoxTempDir=D:\ SET JUMP_BACK_TO=LW_C goto PREPARE_PATH rem Try C: drive for temp... :LW_C SET FirefoxTempDir=C:\ SET JUMP_BACK_TO=NO_VALID_PATH_FOUND goto PREPARE_PATH :NO_VALID_PATH_FOUND echo ERROR: No valid temporary path was found. exit /b :COPY_NOW rem create batchfile "errlvl0.cmd" echo rem *** created by PortableFirefoxLive.bat *** >%FirefoxTempDir%errlvl0.cmd echo exit /b 0 >>%FirefoxTempDir%errlvl0.cmd rem Copying now ... echo Copying Firefox to a temporary local directory... echo SOURCE: %FirefoxStartDir% echo DESTINATION: %FirefoxTempDir% echo. xcopy %FirefoxStartDir%* %FirefoxTempDir% /E /Q >nul 2>nul if errorlevel 1 ( rem first clean up errorlevel :-) CALL %FirefoxTempDir%errlvl0.cmd echo ERROR: Unable to copy Firefox to temp directory. Aborting. pause goto CLEANUP ) echo Starting Firefox... pushd %FirefoxTempDir% rem Example to start Firefox with bookmarks.html or an index.html rem PortableFirefox.exe file:///%FirefoxStartDir%/profile/bookmarks.html rem PortableFirefox.exe file:///%~d0/SubDir/index.html PortableFirefox.exe file:///%~d0/index.html popd if errorlevel 1 ( rem first clean up errorlevel :-) CALL %FirefoxTempDir%errlvl0.cmd pause ) rem Pause for 5 seconds to ensure Firefox still works echo ... and waiting for 5 seconds until Firefox still works PING 1.1.1.1 -n 1 -w 5000 >NUL echo. echo At first close Firefox after use!! echo Than follow next Step to clean up temporary files for echo Closing this PortableFirefoxLive.bat ... pause echo. rem Pause for 5 seconds to ensure Firefox is fully closed echo ... waiting for 5 seconds to ensure Firefox is fully closed PING 1.1.1.1 -n 1 -w 5000 >NUL :CLEANUP echo. echo Cleaning up temporary files... rmdir %FirefoxTempDir% /S /Q IF EXIST %FirefoxTempDir% ( echo. echo The Temp-Directory %FirefoxTempDir% couldn't clean up!! echo Change directory and delete files by using comandline or filemanager. pause ) exit /b :HOW_TO_USE echo "PortableFirefoxLive /?" echo Display this help information echo "PortableFirefoxLive" echo Starts Firefox in one of the following locations: echo TEMP, TMP, D:\ und C:\ echo "PortableFirefoxLive " echo Starts Firefox in the indicated path. On failure, tries above. pause exit /b :PREPARE_PATH IF NOT EXIST %FirefoxTempDir% ( echo %FirefoxTempDir% not found SET FirefoxTempDir= goto %JUMP_BACK_TO% ) :AGAIN IF "%FirefoxTempDir:~-1%"=="\" SET FirefoxTempDir=%FirefoxTempDir:~0,-1% IF "%FirefoxTempDir:~-1%"=="\" goto AGAIN SET FirefoxTempDir=%FirefoxTempDir%\FirefoxTempDir\ md %FirefoxTempDir% 2>nul if errorlevel 1 ( echo ERROR: No write access to %FirefoxTempDir% - Aborting SET FirefoxTempDir= goto %JUMP_BACK_TO% ) goto COPY_NOW rem +++ Adapted From: OPERA FROM USB-STICK - WWW.TORSTEN-KEIL.NET +++ rem +++ LAST LINE OF SCRIPT +++