?
Solved

Add and remove network printer by group policy

Posted on 2007-08-01
11
Medium Priority
?
438 Views
Last Modified: 2008-01-09
I am trying to find a way to do the following by group policy. This would have to work for users that do not have local admin rights.

1) Add new network shared printer (ex. \\computer\printer)
2) Add new network printer attached to new local tcp/ip port by IP Address or DNS name (ex. 192.168.1.20 or printer.localdomain.com)
3) Set the new printer as default
4) Remove old network printer that was attached to by TCP/IP port (ex. Printer = HP Laserjet and Port = IP_192.168.1.10)

Thanks in advance
0
Comment
Question by:vnights
  • 5
  • 5
11 Comments
 
LVL 70

Expert Comment

by:KCTS
ID: 19613584
You cannot do this directly with group policy but you could devise a script to do this and use group policy to run the script at logon.
0
 

Author Comment

by:vnights
ID: 19613694
I guess it was more of the script to run with GP that I was looking for.
0
 
LVL 19

Expert Comment

by:Andrew Davis
ID: 19613710
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:vnights
ID: 19613919
I am looking for someone to show me a good clean script that I can add to a GP to perform all of the above items.

Thanks in advance
0
 
LVL 19

Expert Comment

by:Andrew Davis
ID: 19614058
the scripts in the above link will do that. you will need to alter them for your domain and your printer names. and you will need to save them on your server as logon script and point your gpo to it. If you want us to do the work for you then you are mistaken about our ability. we cannot customize it for your domain without the domain name and the printer names, but then what are you going to do when you need to add another printer in the future.
0
 

Author Comment

by:vnights
ID: 19614149
Andrew,

The links provided do not help with items 2 and 4. Some of the printers being added and removed do not have a print server. They are printers with network cards in them and the computers print directly to them.

I have already been able to accomplish the rest of the items but could never get 2 and 4 working. I am looking to get those pieces working and get all of the items into a clean script.

Also I gave examples for each piece of information that I thought would be needed in the script above. Like the IP Address, Printer Name, Port Name, DNS name, etc.
0
 
LVL 19

Expert Comment

by:Andrew Davis
ID: 19615265
2) Add new network printer attached to new local tcp/ip port by IP Address or DNS name (ex. 192.168.1.20 or printer.localdomain.com)
Why would you want to do this. Then you have no control over the printer an must ensure all the clients set the configuration (paper size, tray config...) themselves. why wouldnt you connect it to your print server and then let them connect to that. That way you get control of your network. That said most ip printers will have a share that you can hook to eg \\ip address\{print que} but where are they going to get the driver from..... Ahh i know, put it on a print server.

4) Remove old network printer that was attached to by TCP/IP port (ex. Printer = HP Laserjet and Port = IP_192.168.1.10)
see http://www.experts-exchange.com/Programming/Misc/Q_20857609.html
and http://www.computerperformance.co.uk/Logon/Logon_Remove_Printer.htm
0
 

Author Comment

by:vnights
ID: 19615357
In response to #2 - The client does not want one particular printer to go through a server, they want the desktops to print directly to it.

In response to #4 - Your first link appears to be for someone that wants to remove ALL printers. I need to get rid of one specific one. Your second link shows examples for removing printers by a UNC path. This printer is not connect in that way, it has a TCP/IP port added locally for the printers IP. I don't know if this means that this is now considered a local printer or not. But if it does I tried placing it's name in quotes like the page says. When I run this it comes back and says "This network connection does not exist". If you think this page has what I am looking for please update my code below to what it should be.

Thanks


Option Explicit
Dim objNetwork, strUNCPrinter, bForce, bUpdateProfile
strUNCPrinter = "LANIER LD238c PCL 5c"
bForce = "True"
bUpdateProfile = "False"

Set objNetwork = CreateObject("WScript.Network")
' Section which removes the network printer
objNetwork.RemovePrinterConnection strUNCPrinter, bForce, bUpdateProfile

WScript.Echo "Check Printers folder NO: " & strUNCPrinter
Wscript.Quit
0
 
LVL 19

Expert Comment

by:Andrew Davis
ID: 19621438
#2 The client doesnt want to control the printer by way of the network, yet they want to install it by way of the network. The client is silly. You will have problems with the driver location. You could do it by way of autoit (google autoit), or just do it manually on each client and charge the client fro being so silly.

#4 i had a look at the script and created a simple hp laserjet 4 printer on my system with it connected to a simple tcp/ip local port, and your right it doesnt work ;) however i found another way that works fine.

-------------Beginning of script----------------
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer where DeviceID = 'LANIER LD238c PCL 5c'")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
-------------End of Script-----------------------

Try that
from http://www.visualbasicscript.com/m_1208/tm.htm
0
 

Author Comment

by:vnights
ID: 19628573
That script works good if you have admin rights, any way for non-admin users?
0
 
LVL 19

Accepted Solution

by:
Andrew Davis earned 1500 total points
ID: 19630109
Ok you will need to call the script from another script using the runas command. see http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
An article on effective troubleshooting
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

809 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