Link to home
Start Free TrialLog in
Avatar of Ben_Gillam
Ben_Gillam

asked on

Add network printers using a login script

I regularly set up Windows 2000/2003 Servers and usually with several network printers, but we came up against a problem recently on an install. We had about 15 printers running of various print servers and about 30 machines. We were able to set up the mapped drives fine using a bunch of net use x: \\server\folder 's but we couldnt work out a way of doing somthing similar with printers. IE when someone logs onto the machine it makes sure the printers are installed.

Would save me a hell of a lot of time if there was a way to do this
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ben_Gillam
Ben_Gillam

ASKER

thanks for quick reply, I shall give this a try.

*****Printers*****

You are mapping an "lpt" port (Line Printer Terminal) All the rules above apply so the full command is,

net use lpt1 \\machinename\sharename\ /user:username password /Y

Zero Administration Kit
http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

How to Use Con2prt.exe to Connect to a Network Printer
http://support.microsoft.com/?kbid=181663


Pete
Hi Ben

In my environment we put a 'Call' command in the login script that calls a file that contains the con2prt command. An example of this Call command is;

CALL "%logonserver%\netlogon\printers\%computername%.CMD

This way you can set up a file for each machine by their computername. An example of what this file contains is;

con2prt /cd \\<printserver name and path>\<Printer Name>

Note that the d in the /cd makes the printer a default printer whereas /c will just add it.

The con2prt command is available at;

http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

Hope that this is of some assistance.
hi
this may be what you are after

rundll32 printui.dll,PrintUIEntry /in /n \\yourprintserver\printer 1
rundll32 printui.dll,PrintUIEntry /y /n "printer"      

this will install whatever printers and second line will set a default

I was using con2prt.exe but I have changed since I want more control now. You can use Windows Scripting Host and do something like this:

Set oNet = CreateObject("WScript.Network")
Set oArgs = Wscript.Arguments
printer = oArgs(0)
oNet.AddWindowsPrinterConnection printer

Then, have your login script (.cmd) call "wshFile.vbs \\server\printshare".

There are other functions for the WScript.Network Object (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsobjwshnetwork.asp) that you should check out for removing or enumerating printers.

I am just starting to use this method, but it looks quite nice. The power of control is not in the functions, but in the scripting now.

Chris