Skip to content

Instantly share code, notes, and snippets.

@tresf
Last active April 4, 2024 16:15
Show Gist options
  • Save tresf/bb070446f456964b3e39befa9294c469 to your computer and use it in GitHub Desktop.
Save tresf/bb070446f456964b3e39befa9294c469 to your computer and use it in GitHub Desktop.
Unofficial QZ Tray + 7zip Installer
@ECHO OFF
SET INSTALLER=qz-tray-2.2.3-x86_64.exe
SET TEMPQZ=%USERPROFILE%\tempqz
SET SEVENZIP=%PROGRAMFILES%\7-Zip\7z.exe
REM Preflight: Check for admin
NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
REM Admin confirmed
) ELSE (
COLOR 0C
ECHO.
ECHO +--------------------------------------------------------+
ECHO ^| PLEASE RE-RUN THIS SCRIPT AS ADMINISTRATOR ^|
ECHO +--------------------------------------------------------+
ECHO.
PAUSE
COLOR
EXIT /B 1
)
REM Preflight: Check for 7-zip
IF EXIST "%SEVENZIP%" (
REM 7-zip was found
) ELSE (
COLOR 0C
ECHO.
ECHO +--------------------------------------------------------+
ECHO ^| 7-ZIP WAS NOT FOUND ^|
ECHO +--------------------------------------------------------+
ECHO.
ECHO 7-Zip was expected at "%SEVENZIP%" but it was not found.
ECHO Please correct and re-run this script.
ECHO.
PAUSE
COLOR
EXIT /B 1
)
REM Preflights are OK!
ECHO.
ECHO +--------------------------------------------------------+
ECHO ^| THIS SCRIPT WILL INSTALL QZ TRAY USING 7-ZIP ^|
ECHO +--------------------------------------------------------+
ECHO.
ECHO Press Ctrl + C to cancel
PAUSE
REM Cleanup from previous failed installers
ECHO.
ECHO +------------------------+
ECHO ^| CLEANUP ^|
ECHO +------------------------+
ECHO.
ECHO Ensuring "%TEMPQZ%" is empty...
del /s /q "%TEMPQZ%" > NUL:
REM Extract
ECHO.
ECHO +------------------------+
ECHO ^| EXTRACTING ^|
ECHO +------------------------+
ECHO.
ECHO Extracting files from "%INSTALLER%" to "%TEMPQZ%"...
"%SEVENZIP%" x "%USERPROFILE%\Downloads\%INSTALLER%" -o"%TEMPQZ%" > NUL:
REM Common paths
SET JAVA=%TEMPQZ%\$PLUGINSDIR\payload\runtime\bin\java.exe
SET JAR=%TEMPQZ%\$PLUGINSDIR\payload\qz-tray.jar
REM Run preinstall
ECHO.
ECHO +------------------------+
ECHO ^| PREINSTALL ^|
ECHO +------------------------+
ECHO.
"%JAVA%" -jar "%JAR%" preinstall
REM Run install
ECHO.
ECHO +------------------------+
ECHO ^| INSTALL ^|
ECHO +------------------------+
ECHO.
"%JAVA%" -jar "%JAR%" install
REM Run certgen
ECHO.
ECHO +------------------------+
ECHO ^| CERTGEN ^|
ECHO +------------------------+
ECHO.
"%JAVA%" -jar "%JAR%" certgen
REM Cleanup temp files
del /s /q "%TEMPQZ%" > NUL:
REM Note, QZ Tray will need to be started manually
ECHO.
ECHO +------------------------+
ECHO ^| FINISHED ^|
ECHO +------------------------+
ECHO.
ECHO You'll need to start QZ Tray manually.
ECHO.
PAUSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment