Jump to content
Sign in to follow this  

Rename a client printer in a Windows 2003 TS

Recommended Posts


Good evening all,

I was wondering whether someone would be able to help / advise me with the following scenario:

I have a program which requires a client printer to have a specific name in order to print to it. When a user logs onto Terminal Services in a Windows server 2003 environment, the local printer is mapped with the following name:

"<Printer name> (from <PC Name>) in Session #"

When I rename the printer to its original name e.g. HP LaserJet 2200 PCL 6 the program works ok. However as soon as a user logs out and back in the issue arises again.

Ive searched the forums to locate a sample script which would rename a printer if it meets a specific requirement i.e. a printer name contains (from and in Session which will then truncate the printer name accordingly, but I've had no success

Any help would be appreciated.

[u]Words of Wisdom and Favourite Quotes:[/u]'Nothing is impossible, despite what other people say and think, prove them wrong and show them what you can do!''Understanding is a three edged sword, your side, their side and the truth!''Nothing, I shoot ever gets back up again!''The truth that humanity has never been able to grasp, is that death may be the only absolute freedom there is!''The answer's no, now what's the question?''I hear what you're saying, but we're gonna do it my way!''You don't keep me informed' > 'But I sent you an e-Mail regarding this issue and you read it!' > 'oooh you can't expect an e-Mail to register!''How are you today?' > 'Fair to suicidal!'

Share this post

Link to post
Share on other sites

While not a true AutoIt script, here is a WSH script I wrote that will set the users default printer to whatever printer is seen in the current session that contains the name of the client making the connection.

var oShell=WScript.CreateObject("WScript.Shell");
var ThinClientID=oShell.ExpandEnvironmentStrings("%ClientName%");
var WshNetwork=WScript.CreateObject("WScript.Network");
//list of printers installed
var oDevices=WshNetwork.EnumPrinterConnections();
var localDefault='';
for(var i=0;i<=oDevices.length-2;i+=2)
{   var devName=oDevices(i+1).split('/');
    //we expect the name of the PC to be the 2nd part of the array
    {   localDefault=oDevices(i+1);

Eventually I'll clean this up and make an AutoIt version but this should help point you in the right direction.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this