RTFM Education – Virtualization, VMware, Citrix

Oct 20 2005   11:33AM GMT

Setting the Default Printer in Citrix



Posted by: MikeLaverick
Tags:
Citrix

Firstly, Citrix cannot do this – all Citrix cannot set the default printer. It can exclude all other printers BUT the default printer – but it cannot set it. The only time you can set the default printer within Citrix is by using Session Printers (using the Import Printer Server feature and Policies – this was introduced with MFPF4.0)

In all circumstances, Citrix sets the default printer based on the client device settings – does is check the client configuration and “auto-create” the same preferences in the Citrix session. So to manipulate this we have to use windows scripts or a combination of scripts and publishing. This is outlined in CTX-102605  – this article links to CTX884335 in which the Citrix “solution” is to publish the printers folder – to allow users to change the default. Unfortunately, this also exposes the “Add Printer” wizard as well.

In the support forum – members have offered their own work a rounds – the problem is corrected by a number of methods:

KixStart Method: (Posted by user called Mike Bianco)

Kixstart tools is a command-line script enhancer, which was made by another company, and MS made it part of the Resource Kit. This method uses a kixstart tool called con2prt to set the default printer in combination with net use command. Matt’s method checks the existence for a file in the home directory – and from the main logon script calls a user a logon script. I think this could be simplified to set a global value.

echo Running personal login script…
if exist j:\personal\%USERNAME%.bat call j:\personal\%USERNAME%.bat > NUL

Each user has a .bat file with their user name. Here’s the script we run within the personal script for each user’s printer mapping:

@echo off

net use lpt1: \\printserver\helpdesk /persistent:no /yes
j:\files\con2prt.exe /cd 
\\printserver\helpdesk

:end

VBS/WSH Method (Posted by PC54GH1 – on Strike)

This is my preferred method – its simpler – requires no special files – and is the way forward for problems like this one. You create a file with the VBS extension with this code:

Set WshNetwork = WScript.CreateObject(“WScript.Network”)
PrinterPath = “
\\printerserver\sharename
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter PrinterPath

The next stage is applying this to the client machine. You have three main methods:

  • Active Directory: (Recommended if you have control over the client machine)
    Do this via a Active Directory Group Policy and this sets the default printer in the main client operating system – prior to use the starting the Citrix session.
  • Start-Up Folders: (Not Recommended)
    if you publish a desktop you can do this by putting the script in the Start-up Folder for ALL-USERS, so the script runs every time the desktop is initialised. However, this does not work for published applications such as word.
  • Logon Script Invoked: (Recommended)
    The script has to run after the desktop is initialised NOT before – and therefore will fail if called directly in system or user logon scripts – as these run BEFORE the desktop is initialised. Instead the VBS must be started after the logon script has ended, and wait a short while for printers to be mapped. We cannot change the default printer settings until the printers has been established – and this takes a while in Citrix after the desktop or application is invoked. This achieved by calling the printer.vbs file from the logon script using Microsoft’s built in “start” command – and by adding a “sleep” instruction to the VBS file  Note:
    As well as setting the default printer – it will also create the connection to the printer if it is not there already – which is kinda neat I think!

The VBS Script Set-up Proceedure

  1. Edit the printer.vbs file to read as below:wscript.Sleep 5000
    Set WshNetwork = WScript.CreateObject(“WScript.Network”)
    PrinterPath = “
    \\instructor2\epson
    WshNetwork.AddWindowsPrinterConnection PrinterPath
    WshNetwork.SetDefaultPrinter PrinterPath

    Note:
    Here the sleep is for 5 seconds – you can length or shorten this value based on the time it takes to load the desktop or application
  2. Copy the printer.vbs file to the windows\system32 or winnt\system32 directoryNote:
    It can be run by just double-clicking it – do this to check your script actually works!
  3. Edit usrlogon.cmd and add to the VERY END of the logon scriptstart %systemroot%\system32\printer.vbsWarning:
    For the above to work you must have set the “root drive” variable within rootdrv2.cmd. I recommend putting a pause statement just before this line – to check that the VBS is actually running. By default it runs silently with no UI – so it can be difficult to know if its running. Alternatively add this to the end of the vbs fileFor the above to work you must have set the “root drive” variable within rootdrv2.cmd. I recommend putting a pause statement just before this line – to check that the VBS is actually running. By default it runs silently with no UI – so it can be difficult to know if its running. Alternatively add this to the end of the vbs filewscript.echo “Your default printer has been set to Epson on Instructor”This will display a dialog box once the script has end

    This will display a dialog box once the script has end

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: