Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create script to add printer locally to all clients

Status
Not open for further replies.

ScottCGI

IS-IT--Management
Dec 20, 2004
141
US
I have a windows 2003 file server with xp clients. I have a couple of new printers I created and instead of touching each client I want to create a script that will add these printers locally for each client when they login to the network. I used the following script to delete the old one and it worked great:

start rundll32 printui.dll,PrintUIEntry /dl /q /n\\servername\printername

How do I modify this script to add the new printer???




Scott
 
With regards to PrintUI you would use the following:
rundll32 printui.dll,PrintUIEntry /in /y /n \\server\printer
 
Is there a way to script this? I would like to have a script that would check the box under the ENVIRONMENT tab that says "Connect Client Printers"...

I'd rather not have to go into each client and check the box??

Any help????


Thanks in advance!!
Brandon
 
OK. To install a network printer on a local machine, do this in vbscript:

Code:
Set WshNetwork = CreateObject("WScript.Network")

WshNetwork.AddWindowsPrinterConnection "\\Your_PrintServer\printer_share"

'If you want it to be default use the following line
WshNetwork.SetDefaultPrinter "\\Your_PrintServer\printer_share"
 
I understand that code... however, what I am trying to accomplish is checking the box on the Environment Tab (under a users account) to "connect client printers".

I don't know the file/print server or the printer share name. I just want to check the box inside of their user account that does this automatically... Is this possible?


Thanks!!!
Brandon
 
AD-
Here's the big picture...
Our users (lots of them) will be connecting from a remote location (at a hotel confrence) from several different laptops that are workgrouped. There is one printer that all of the workgrouped laptops will connect to.

Now, all laptops will traverse the internet to connect back to our Citrix Server (using a web client). They will use our domain credentials to log into our Citrix Farm.

The reason I need to check the "Connect Local Printers" box in AD is so that their 'local' printer (from laptop) will get mapped as they log into Citrix...
 
Ok. Here is a script to check that box in the environment tab for a user in ADUC.

Code:
Set objUser = GetObject("LDAP://CN=Your, User_DN,OU=Users,DC=domain,DC=local")
objUser.ConnectClientPrintersAtLogon = 1
ObjUser.SetInfo

If you need it for ALL users or a larger group, it can be written to do all or just selected people.
 
Ok- got it to work... ONE MORE QUESTION! :)

How can I specify all users in a particular OU, rather than changing the cn everytime??

MANY THANKS!!!!!!!!!!!

Brandon
 
Try this then:

Code:
set objParent = GetObject("LDAP://OU=Users,DC=domain,DC=local")
objParent.Filter = Array("user")
for each objUser in objParent

Set objUser2 = GetObject("LDAP://CN=UserLast, UserFirst,OU=Users,DC=domain,DC=local")
objUser2.ConnectClientPrintersAtLogon = 1
ObjUser2.SetInfo
next

It can also be set to prompt you for a user or OU name or something simple. Setting up a prompt for any information and/or requiring something simple like username instead of DN is very easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top