Add and remove network printer by group policy

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
vnightsAsked:
Who is Participating?
 
Andrew DavisConnect With a Mentor ManagerCommented:
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
 
Brian PiercePhotographerCommented:
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
 
vnightsAuthor Commented:
I guess it was more of the script to run with GP that I was looking for.
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
vnightsAuthor Commented:
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
 
Andrew DavisManagerCommented:
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
 
vnightsAuthor Commented:
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
 
Andrew DavisManagerCommented:
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
 
vnightsAuthor Commented:
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
 
Andrew DavisManagerCommented:
#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
 
vnightsAuthor Commented:
That script works good if you have admin rights, any way for non-admin users?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.