:: :: Drop files to this cmd to open with Firefox via jar: protocol :: :: Version: 1.0.5 :: Author: Danny Lin :: License: MIT :: @echo off chcp 65001 set CMD="" "firefox" -private-window :: define ZIPCMD if 7z is available if not defined ZIPCMD call :check_app "7z" if not defined ZIPCMD call :check_app "%ProgramFiles%\7-Zip\7z.exe" if not defined ZIPCMD call :check_app "%ProgramFiles%(x86)\7-Zip\7z.exe" :loop set "F=%~1" set F1=%1 setlocal EnableDelayedExpansion if defined ZIPCMD ( for /F "delims=" %%S in ('"!ZIPCMD! !F1!"') do ( endlocal set "S=%%S" setlocal EnableDelayedExpansion :: check whether this is a valid line for directory if "!S:~13,1!" == ":" if "!S:~20,1!" == "D" ( :: "^!" escapes "!" in double quotes (normally "^^!" escapes "!") set "U=jar:file:///!F!^!/!S:~53!/index.html" :: replace "%" with "%25" ("%%" escapes "%") set "U=!U:%%=%%25!" :: replace "#" with "%23" ("%%" escapes "%") set "U=!U:#=%%23!" start !CMD! "!U!" ) ) ) else ( :: "^!" escapes "!" in double quotes (normally "^^!" escapes "!") set "U=jar:file:///!F!^!/" :: replace "%" with "%25" ("%%" escapes "%") set "U=!U:%%=%%25!" :: replace "#" with "%23" ("%%" escapes "%") set "U=!U:#=%%23!" start !CMD! "!U!" ) endlocal shift if not "%~1" == "" goto loop exit /b :check_app set PASS=1 where %1 >nul 2>nul if not %errorlevel% == 0 if not exist %1 set PASS=0 if %PASS% == 1 set ZIPCMD=%1 l "-x!*\*" exit /b