Modified load balancing behaviour

Printer Load balancing in Print Distributor works by sending each document to a different printer in turn so that the print load is spread evenly across the pool of printers. There are some circumstances where you might want to modify this behaviour slightly. For instance if a user prints several documents in quick succession they will prefer to see them all go to the same printer. We can implement this with the Load Balancing action and some scripting in Print Distributor.

This script will work by saving the name of the last printer used in a file based on the users name, start by creating an empty folder C:\Archive to store these files.

Next create a virtual printer in Print Distributor and add a Script action, then paste in the following code:

' Has the user printed recently

Option Explicit

Dim objFS, objTS, strPrinter, objFile, timeout

' Change the timeout to set the number of seconds the user continues to
' use the same printer

timeout = 600

Set objFS = CreateObject("Scripting.FileSystemObject")
If objFS.FileExists("C:\Archive\" & UserName) Then
    Set objFile = objFS.GetFile("C:\Archive\" & UserName)

    If Abs(DateDiff("s", Now, objFile.DateLastModified)) < timeout Then 

        Set objTS = objFile.OpenAsTextStream()
        strPrinter = objTS.ReadLine()

        RePrint PrintFilePath, strPrinter, DocumentName

        SkipNextAction = true
    End If
End If

Now add a Load Balancing action and in that action add a RePrint action for each printer in the pool.

Finally close the Load Balancing and add a final Script action with the following code:

' Save last printer

Option Explicit
Dim objFS, objTS

If Len(LastPrinter) > 0 Then

    Set objFS = CreateObject("Scripting.FileSystemObject")
    Set objTS = objFS.CreateTextFile("C:\Archive\" & UserName)

    objTS.WriteLine(LastPrinter)

    objTS.Close

End If

You should end up with three actions like this:

Printer Load Balancing Actions

These scripts work on a timeout basis so if a user hasn't printed for 10 minutes then they will use the next available printer in the pool. If you need to extend this change the value 600 in the first script.