-
Notifications
You must be signed in to change notification settings - Fork 271
Windows Service
Kyle La Barge edited this page Dec 16, 2021
·
35 revisions
- ✅ 2.2 | ✅ 2.1 | ✅ 2.0 | ✅ 1.9 | ...
- Run QZ Tray as a Windows service.
- This configuration utilizes a third party product "NSSM" to register QZ Tray as a service. It's not officially supported, but has been reported to work well by several users/environments.
- NSSM Service Manager: https://nssm.cc/download (Important: The "Prerelease" version is required)
-
If upgrading from QZ Tray version 2.x to 2.2, the old service must be removed
-
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
.
-
Open a command prompt As Administrator
-
Create a
.bat
file that can launch QZ Tray (the below commands will create this file)- QZ Tray 2.2 and newer (Bundled Java)
echo wmic.exe process where "Name like '%%java%%' and CommandLine like '%%qz-tray.jar%%'" call terminate>"%PROGRAMFILES%\QZ Tray\qz-tray.bat" echo "%PROGRAMFILES%\QZ Tray\runtime\bin\java.exe" -Xms512M -jar "%~dp0qz-tray.jar" %*>> "%PROGRAMFILES%\QZ Tray\qz-tray.bat"
- QZ Tray 2.1 and lower
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"
- QZ Tray 2.2 and newer (Bundled Java)
-
Disable auto-start of QZ Tray for ordinary users:
echo 0 > "%PROGRAMDATA%\qz\.autostart"
-
Make a location for SYSTEM certificate whitelist
mkdir "%WINDIR%\System32\config\systemprofile\AppData\Roaming\qz"
-
Copy the
allowed.dat
to the SYSTEM profilecopy /Y "%APPDATA%\qz\allowed.dat" "%WINDIR%\System32\config\systemprofile\AppData\Roaming\qz\allowed.dat"
- 32-bit Java will need to change this to
%WINDIR%\SysWOW64
instead.
- 32-bit Java will need to change this to
- Open a command prompt As Administrator
- If not already, extract NSSM to
C:\
(e.g.C:\nssm
) - Change to the
win64
directory within NSSM.cd C:\nssm\win64
- Install the
QZ Tray
servicenssm install "QZ Tray" "%PROGRAMFILES%\QZ Tray\qz-tray.bat" nssm set "QZ Tray" Description "Browser printing utility"
- Start the service
net start "QZ Tray"
- Check that it's running, look for
QZ Tray
in the services listing.start services.msc
- That's it, the
QZ Tray
service has been successfully installed.
- Before making any changes, make sure to stop the service
net stop "QZ Tray"
- 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"
- Open a command prompt As Administrator
- Change to the
win64
directory within NSSM.cd C:\nssm\win64
- Uninstall the
QZ Tray
servicenet stop "QZ Tray" nssm remove "QZ Tray"
- Re-enable autostart for regular users
del "%PROGRAMDATA%\qz\.autostart"