Skip to content

Windows Service

Tres Finocchiaro edited this page Nov 18, 2019 · 35 revisions
  • ✅ 2.1 | ✅ 2.0 | ✅ 1.9 | ...

Objective

  • Run QZ Tray as a Windows service image

Prerequisites

Steps

Prepare QZ Tray

  1. Warning: Services can't show the "Trusted" dialog! First, whitelist the website with the certificate to be "trusted" by visiting this site and clicking "Remember this decision".
  2. Open a command prompt As Administrator
  3. Create a .bat file that can launch QZ Tray
    echo java -Xms512M -jar "%~dp0\qz-tray.jar" %* > "%PROGRAMFILES%\QZ Tray\qz-tray.bat"
  4. Make a location for SYSTEM certificate whitelist
    mkdir "%WINDIR%\System32\config\systemprofile\AppData\Roaming\qz"
  5. Copy the allowed.dat to the SYSTEM profile
    copy /Y "%APPDATA%\qz\allowed.dat" "%WINDIR%\System32\config\systemprofile\AppData\Roaming\qz\allowed.dat"

Install the Service

  1. Open a command prompt As Administrator
  2. If not already, extract NSSM to C:\ (e.g. C:\nssm)
  3. Change to the win64 directory within NSSM.
    cd C:\nssm\win64
  4. Install the QZ Tray service
    nssm install "QZ Tray" "%PROGRAMFILES%\QZ Tray\qz-tray.bat"
    nssm set "QZ Tray" Description "Browser printing utility"
  5. Start the service
    net start "QZ Tray"

Advanced

  1. Run QZ Tray with a custom Java version (Important: change c:\Program Files\Java\jdk1.8.0_231\bin to point to a proper JDK)
    echo PATH=%PATH%;c:\Program Files\Java\jdk1.8.0_231\bin > "%PROGRAMFILES%\QZ Tray\qz-tray.bat"
    echo java -Xms512M -jar "%~dp0\qz-tray.jar" %* >> "%PROGRAMFILES%\QZ Tray\qz-tray.bat"

Remove the Service

  1. Open a command prompt As Administrator
  2. Change to the win64 directory within NSSM.
    cd C:\nssm\win64
  3. Uninstall the QZ Tray service
    net stop "QZ Tray"
    nssm remove "QZ Tray"
Clone this wiki locally