Reducing the bandwidth consumed by the User Client Tool

KB Home   |   Reducing the bandwidth consumed by the User Client Tool

Note: As of PaperCut version 7.3 this article is some what obsolete. PaperCut now includes a special self-managing version of the client called pc-client-local-cache.exe. This version automatically copies the files to the local hard-drive and manages a local cached version of the client.

This article is preserved for completeness and to offer an alternative option.


If you have a large number of systems running the PaperCut client utility and experience slow startup times, you may be able to use a script to reduce the amount of data it downloads.

The following KiXtart scripts were contributed by Chris from Colchester Royal Grammar School, a power user of PaperCut NG, and may be useful if you are using PaperCut NG for Windows:


InstallLocalPCClient.kix

This script will test for a local installation of JRE-1.5, and if available will copy the client utility from the network and set it to run on startup. If JRE-1.5 does not exist the client will not be installed.

 $Result = InstallLocalPCClient("\\yourserver\PCClient", "%ProgramFiles%\PaperCut NG Client")

 Function InstallLocalPCClient($PCServerDir, $PCLocalDir)
 	; NB NO TRAILING SLASHES in the paths
 	; Returns 0 for error, 1 for installed, 2 for not installed
 	$InstallLocalPCClient = 0

 	DIM $XCopyRes1, $XCopyRes2, $RegRes

 	IF ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment", "CurrentVersion") = "1.5"
 		? "J2SE 1.5 detected. Installing PaperCut NG Client..."
 		?
 		DIM $XCopyRes1, $XCopyRes2
 		SHELL '%WINDIR%\SYSTEM32\XCOPY.EXE "$PCServerDir\*.*" "$PCLocalDir\" /D /C /I /Q /H /R /K /Y'
 		$XCopyRes1 = @ERROR
 		SHELL '%WINDIR%\SYSTEM32\XCOPY.EXE "$PCServerDir\lib\*.*" "$PCLocalDir\lib\" /D /C /I /Q /H /R /K /Y'
 		$XCopyRes2 = @ERROR

 		IF ($XCopyRes1 = 0 AND $XCopyRes2 = 0)
 			"File copy successful. Writing client startup key to registry..."
 			$RegRes = WriteValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "PaperCut NG Client",
                                             '"$PCLocalDir\pc-client-java.exe" /silent /minimized', "REG_SZ")
 			$InstallLocalPCClient = 1
 		ELSE
 			"File copy failed ($XCopyRes1,$XCopyRes2). Removing client startup key from registry..."
 			$RegRes = DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "PaperCut NG Client")
 			$InstallLocalPCClient = 0
 		ENDIF
 	ELSE
 		? "J2SE 1.5 not detected. Removing client startup key from registry..."
 		$RegRes = DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "PaperCut NG Client")
 		$InstallLocalPCClient = 2
 	ENDIF
 EndFunction
 

RunPCClient.kix

This script will test for a local installation of the client utility. If it is installed and up to date, nothing is done. If it is not installed or needs updating, it is run from the server.

 $Result = RunPCClient("\\yourserver\PCClient", "%ProgramFiles%\PaperCut NG Client")

 Function RunPCClient($PCServerDir, $PCLocalDir)
 	; NB NO TRAILING SLASHES in the paths
 	; Returns 0 for locally installed, 1 for running from server
 	$RunPCClient = 1

 	IF ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "PaperCut NG Client") <> ""
 		IF Exist("$PCLocalDir\version.txt") AND GetFileTime("$PCLocalDir\version.txt") = GetFileTime("$PCServerDir\version.txt")
 			COLOR n+/n
 			? "Client is already locally installed. No startup required."
 			COLOR w/n
 			$RunPCClient = 0
 			RETURN
 		ELSE
 			? "Local installation is incorrect or out of date. Running from server..."
 		ENDIF
 	ELSE
 		? "No local installation detected. Running from server..."
 	ENDIF

 	; If the admin is logged in
 	IF @USERID = "YourAdminAccount"
 		$PCServerDir = "\\yourserver\PCClientTest"
 	ENDIF

 	; If we get here there's no local installation, or it's not up to date
 	IF ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment", "CurrentVersion") = "1.5"
 		RUN "$PCServerDir\pc-client-java.exe /silent /minimized"
 	ELSE
 		RUN "$PCServerDir\pc-client.exe /silent /minimized"
 	ENDIF
 EndFunction
 

Categories: User Client Tool, Administration

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on November 04, 2012, at 11:37 PM
Printable View   |   Article History   |   Edit Article