Solved

Add network printers using a login script

Posted on 2003-11-27
7
21,396 Views
Last Modified: 2010-04-14
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
0
Comment
Question by:Ben_Gillam
7 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 250 total points
ID: 9830364
The easiest way to do this is con2prt.exe from the NT4 Zero Administration Kit (still works fine under XP ;).
To map printers (or drives) based on group membership, you can use ifmember.exe from the W2k Resource Kit. If you don't have the Resource Kit, you can download ifmember here: http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp

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

To map a network printer:
con2prt.exe /c \\PrintServer\PrintShare
("/cd \\printserver\share" to install it as default printer; /f to delete all existing connections)

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

A script solution could then, for example, look like this:

====8<----[Logon.cmd sample]----
ifmember.exe YourDomain\Group01
:: *** ifmember returns errorlevel 1 if the user *is* group member!
if not errorlevel 1 goto EndGroup01
net use X: \\FileServer\Group01Share
con2prt.exe /c \\PrintServer\Group01Printer
:EndGroup01
:: ...
====8<----[Logon.cmd sample]----
0
 

Author Comment

by:Ben_Gillam
ID: 9830377
thanks for quick reply, I shall give this a try.
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 9830402

*****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
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Expert Comment

by:wozza_c
ID: 9830430
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.
0
 
LVL 1

Expert Comment

by:msavin
ID: 9831665
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

0
 

Expert Comment

by:chenglan
ID: 10999552
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
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Data off on old Win 2000 server. 18 587
Windows 7 7 265
Upgrading Windows 2000 SP4 to Windows XP SP2 5 379
Automate postgres backups on windows and move it to linux box 15 98
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question