Brian Madden Logo
Your independent source for application and desktop virtualization.
advertisement

script to map printer to %clientname%, in the Scripting / Automation forum on BrianMadden.com

rated by 0 users
This post has 1 Reply | 1 Follower

Not Ranked
Points 55
stuart.macintyre Posted: Fri, Jul 3 2009 2:24 AM

I was looking for a vb script tocreate a printer connection to a local client side printer. Assuming the printer share name is always the same but the clientr name will change. %clientname% gives the correct client name. deleting the printers at log off would be nice as well.

This is for a TS2008 enviroment. Using easyprint or allowing the printers to auto create dont work for this specific printer model. Thats why i want to share the printers on the client machines (all with the same share name) and map the printer based on %clientname% when they log into a TS session on the server.

 

Cheers

  • | Post Points: 5
Not Ranked
Points 55

Got it working used this.

Dim netPrinter, UNCpath
Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
User = CreateObject("WScript.Network").Username
Sh.LogEvent 4, "Logon by " & User & " from " & sys
UNCpath = "\\" & sys & "\EPSONTM-"
Set netPrinter = CreateObject("WScript.Network")
netPrinter.AddWindowsPrinterConnection UNCpath

  • | Post Points: 5
Page 1 of 1 (2 items) | RSS