Wiki - Windows Service

Objective

Prerequisites

Steps

Prepare QZ Tray

  1. Warning: Services can NOT show the "Trusted" dialog. If not already...
    • Visit a website with the certificate that needs to be whitelisted.
    • Click "Remember this decision". This will save a file allowed.dat to %APPDATA%\qz.
  2. Open a command prompt As Administrator
  3. Create a .bat file that can launch QZ Tray
    echo wmic.exe process where "Name like '%%java%%' and CommandLine like '%%qz-tray.jar%%'" call terminate>"%PROGRAMFILES%\QZ Tray\qz-tray.bat"
    echo java.exe -Xms512M -jar "%~dp0qz-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"
  6. Check that it's running, look for QZ Tray in the services listing.

    start services.msc

Advanced

  1. Before making any changes, make sure to stop the service
    net stop "QZ Tray"
  2. 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 set PATH=C:\Program Files\Java\jdk1.8.0_231\bin;^%PATH^%> "%PROGRAMFILES%\QZ Tray\qz-tray.bat"
    echo wmic.exe process where "Name like '%%java%%' and CommandLine like '%%qz-tray.jar%%'" call terminate>>"%PROGRAMFILES%\QZ Tray\qz-tray.bat"
    echo java.exe -Xms512M -jar "%~dp0qz-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"

Troubleshooting

  1. Make sure you can call java from a command prompt

    java -version
    • If java is not available, you may hardcode the path using [[Windows-Service#advanced]] section above.
  2. If initial connection works, but printing, listing printers, fails, make sure you've properly configured signing. [[Signing-Messages]]

Edit this page