Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add network printers using a login script

Posted on 2003-11-27
7
Medium Priority
?
21,445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 1000 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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 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