Monday, December 12, 2011

How to retain a users default printer in Citrix when using Session Printers.

I just covered how to push down Session Printers in Citrix based on Active Directory membership in my last post.  This method does however have one problem and that is that the users Default Printer preference will be discarded upon logout.  To get around that the free Defset utility can be set up in the users login script to restore the previous default printer.  It will also need to be added as a published application for the users to use to change their default printer instead of the normal way.

You will need to download and save theDefSet utility onto each citrix server available form http://www.ctrl-alt-del.com.au/CAD_Utils.htm.  In my case I just saved it to %windir%.

After that you will need to create a Group Policy that will apply to all the Citrix users.  In this policy you will need to add the following batch login script.  The delay is there to ensure all the printers have been generated before the utility is run.

defset.bat
timeout 20
start %windir%\defset.exe /min


This will in essence work now but any client side printers published to the session will break it.  To deal with that we need to make two changes.  First off add the following Citrix Policy to the same Group Policy we already created.
Policy: Client printer names
Value: Legacy printer names

 
Now save the following  VBScript onto your Citrix servers where you put DefSet. Any local printer on the server can be used here and it is only needed to get a fixed default printer prior to DefSet running so there there are no errors.

SetDefault.vbs
Set WSHNetwork = CreateObject("WScript.Network")
WSHNetwork.SetDefaultPrinter "Adobe PDF"
 
Next edit the defset.bat file and added the following line before the DefSet code.
cscript.exe %windir%\SetDefault.vbs
 
Once done when a user loges in first all the printers will be set up by the Citrix Policies and the local shared  printers will be configured as well.  As that is happening the VBScript will set a fixed printer on the server as the default.  After 20 seconds the DefSet tool will launch and restore the users default printer.  The DefSet tool stores the preference in the users home directory witch  should automatically be backed up and restored fir the Citrix Profile manager.

As a final option you can remove the icon from the system tray and add DefSet as a published application.  We like a clean System tray so I also added the following lines to the end of defset.bat to close the system tray icon after a few seconds.
timeout 3
taskkill /FI "IMAGENAME eq DEFSET.exe" /FI "USERNAME eq %username%"

Please note that changing the default printer must be done with the DefSet tool and changing the printer in Windows will still be ignored on logoff.

0 comments: