Choose your language

Choose your login

Support

Controlling printer access based on time

THE PAGE APPLIES TO:

Controlling printing times with print scripts

Controlling access to printers based on time can be useful in a number of circumstances. Since PaperCut 10.1 the simplest way to achieve this is with the Advanced Scripting feature. Scripting allows for writing small scripts in Javascript to control and customize how print jobs are handled by PaperCut.

In this case, a script can test the time of the print job. If during a particular time of day the job can be cancelled and a message sent to the user (via the user client software). Sample scripts are available as recipes and snippets within the PaperCut admin interface, under Printers > [select printer] > Scripting > Import recipe.

Below is an example of a PaperCut script that controls printer access based on the time of day and the day of the week. (It is a screen capture so it cannot be copied and pasted into a PaperCut script window).

The script shows the basic principles of time-based control of print jobs in PaperCut (sometimes called time-based printer access).

  • job date/time is in inputs.job.date
  • inputs.job.date is a java.util.Date
  • day codes are 0=Sun, 1=Mon, 2=Tue etc.
  • a 24 hour clock is used.

This script will cancel all print jobs that were submitted to the PaperCut printer it belongs to if they occur outside of 8.30 am to 5.30 pm Monday to Friday.

For documentation on Advanced Print Scripting see the manual.


Controlling printing times with web-services or server commands (before version 10.1)

PaperCut comes with a comprehensive set of XML web services API’s and a set of command-line tools for use in traditional scripting environments such as batch files or shell scripts. These tools can be used to control accounts, settings and printer access. One example of their use is controlling printer access based on time of day. Here is an example on how to set this up:

This example assumes:

  • PaperCut NG is set up on a Windows print server named “printsrv1”
  • There is a printer access on the server called “labprinter”
  • The administrator would like the printer disabled between 5:00pm and 8:00am on week days.

1. Log into the server as administrator

2. Create two text files (renamed to bat files) called:

        open-printer-access.bat
        close-printer-access.bat

in the location C:\Program Files\PaperCut NG\server\custom

3. In close-printer-access.bat add the text:

        cd c:\program files\papercut ng\server\bin\win
        server-command.exe disable-printer “printsrv1” “labprinter” −1

Note: The value -1 indicates to disable the printer forever - that is until is is manually re-enabled.

4. In open-printer-access.bat add the text:

        cd c:\program files\papercut ng\server\bin\win
        server-command.exe enable-printer “printsrv1” “labprinter”

5. Double-click on close-printer-access.bat and verify that the printer is disabled and printing is denied. Then Double-click on open-printer-access.bat and verify that printing is re-enabled.

6. Use the Windows Task Scheduler under Start->Control Panel->Scheduled Tasks to add two new tasks as follows:

  • Schedule close-printer-access.bat to run on at 5:00pm on weekdays.
  • Schedule open-printer-access.bat to run on at 8:00am on weekdays.

Note: More information on the Windows Task Scheduler in the Windows help system.

For more information see Scheduling server commands.


Categories: How-to Articles , Print Queues


Comments

Last updated September 6, 2024