PaperCut Client

PaperCut is commercial print-management software. The client displays a user's balance and is necessary if you want to write scripts that interact with the user.

General information on client installation is in the documentation. PaperCut recommends their zero-install strategy, but this requires additional permissions on the client PC, so this recipe is built around using the MSI.

Start by following the Deployment on Windows via Silent Installer MSI instructions: take the entire client/win directory from one of your PaperCut servers and copy it into your software deployment share, then make any pre-deployment changes you want per the PaperCut documentation.

If you only copy the MSI and ignore the other files in the same directory, the installation will fail.

Quirks

  • If installed from an MSI, the PaperCut client doesn't show up in Programs and Features, but WPKG uninstall checks do see it.
  • If the installation fails because files are missing, check that you copied the entire client/win directory into your deployment share. If you did copy everything and the installer still needs files you don't have, your server installation may be damaged and missing files.

XML

The sample XML assumes that %SOFTWARE% contains a directory called papercut, and that within it are separate directories for each version of PaperCut. The PaperCut documentation recommends keeping installers for different versions of the client separate, and the <remove> stanzas in this package definition rely on old versions still being available.

Set %PKG_EDITION% to MF or NG, depending on which edition of PaperCut you use.

This package uses PowerShell to perform a registry check, which means you'll have to depend on a PowerShell package or change the check to use it on versions of Windows that shipped without PowerShell (i.e. Vista / Server 2008 and older). It should work on all versions of PowerShell, but it's only been tested on PowerShell 3.

<package
   id="papercut-client"
   name="PaperCut Client"
   revision="%PKG_VERSION%-%PKG_PKGREV%"
   reboot="false"
   priority="10">

   <variable name="PKG_VERSION" value="14.3" />
   <variable name="PKG_PKGREV" value="6" />
   <variable name="PKG_EDITION" value="MF" />

   <variable name="PKG_DESTINATION" value="%PROGRAMFILES%\PaperCut %PKG_EDITION% Client" architecture="x86" />
   <variable name="PKG_DESTINATION" value="%PROGRAMFILES(x86)%\PaperCut %PKG_EDITION% Client" architecture="x64" />

   <!--
        This registry check doesn't work, possibly due to WPKG bugs or
        undocumented behavior involving " in the value.

        The ugliness with &#45;&#45; is because XML does not allow double
        dashes in comments. For details, see
        http://stackoverflow.com/questions/10842131/xml-comments-and
     -->
<!--
   <check type="registry" condition="equals" path="HKLM\Software\Microsoft\Windows\CurrentVersion\Run\PaperCutClient" value="&quot;%PKG_DESTINATION%\pc-client.exe&quot; &#45;&#45;silent"  />
-->

   <!-- ... and for reasons I couldn't figure out, %COMSPEC% /c reg query | find
        worked on the command line but not in wpkg, so instead we have this abomination:
    -->
   <check type="execute" condition="exitcodeequalto" path="powershell -noprofile -command &quot;if ($(get-itemproperty -ErrorAction silentlycontinue -path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run -Name PaperCutClient | select-object -ExpandProperty PaperCutClient) -eq \&quot;`\&quot;${Env:PKG_DESTINATION}\pc-client.exe`\&quot; &#45;&#45;-silent\&quot;) { return 0 } else { return 1 }&quot;" value="0"  />
   <!-- Fun fact: we're using three different ways to encode " here! -->

   <check type="uninstall" condition="versiongreaterorequal" path="PaperCut %PKG_EDITION% Client" value="%PKG_VERSION%" />
   <check type="file" condition="exists" path="%PKG_DESTINATION%\pc-client.exe" />

   <install cmd='msiexec /qn /i "%SOFTWARE%\papercut\%PKG_VERSION%\pc-client-admin-deploy.msi"' />

   <install cmd='"%WINDIR%\system32\reg.exe" add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v PaperCutClient /d "\"%PKG_DESTINATION%\pc-client.exe\" --silent" /t REG_SZ /f' />

   <upgrade include="install" />
   <downgrade include="install" />
   <remove cmd='msiexec /qn /x "%SOFTWARE%\papercut\%PKG_VERSION%\pc-client-admin-deploy.msi"' />
   <remove cmd='reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v PaperCutClient /f' />


</package>
</code>