Discussion Locked

Terminal Server Script for printers

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is there anyway to identify what the name of the client is that the user is logging on from? For example I have computerA and computerB, in a script running on terminal server can I tell if the user is using computerA or computerB. I want to be able to set the default printer based on the computer that they using to log into Terminal Server. I know how to set the default printer I just need to be able to tell what computer they are on. Not every computer has a printer so I want to default to the closest printer to that computer. Any help is greatly appreciated.

7 replies

by ben.morton

You could assign the user accounts terminal services scripts so that when they sign on they print the current user name and machine name to a text file?

by nbcasey

If you are just using batch scripting, you can use %clientname%. Works for NT4 and 2K Terminal server. If you are doing some vbscripting and using Citrix, you can use some of Citrix's objects. For Example:
set ica = createobject("Citrix.ICAClient")
computername = "\\" & ica.clientname
Good Luck!

by nbcasey

You can still use the %clientname% in vbscript.. for example:
set oShell = CreateObject("Wscript.Shell")
computername = oShell.ExpandEnvironmentStrings("%clientname%")

As for mapping printers, use the Network object. Ex:
set oNet = CreateObject("Wscript.Network")
oNet.AddWindowsPrinterConnection "\\printserver\printshare"

You can add windows printers from command line, but its a little more complex. You have to make sure the driver names match exactly to what Windows has it as. Ex: Some of the lines below may appear word wrapped, but they are all one line.

REM Adds the printer - This would add a local printer
rundll32 printui.dll,PrintUIEntry /if /b "PRINTERNAME" /f "C:\_950drv\2kxpinf\enu\drivers\win2k_xp\hpf950k.inf" /r "lpt1:" /m "hp deskjet 950c series"

REM Set printer to default..
rundll32 printui.dll,PrintUIEntry /y /n "PRINTERNAME"

REM Adds a network printer
rundll32 printui.dll,PrintUIEntry /in /n "\\printserver\printer"

You can also just do "rundll32 printui.dll,PrintUIEntry /?" to get all the options. This tool can do many cool things! Personally, I would stick with VBScripts. Much easier to manage in my opinion. Hopes this helps.

by greg.gotcher

I am writing vbscripts but I am not using Citrix. Is there a way to get the client name without Citrix. Or how do I set a default printer using batch scripts?

This discussion is closed to new replies.