Link to home
Start Free TrialLog in
Avatar of rick81
rick81

asked on

GPO, GPP, Script to remove network printer

ok i know this question has been asked 1000's of times, however here is my issue.
i am trying to remove network printers with the above methods.  server is win2003, clients win7, without admin rights.

i have tried GPO, GPP and shutdown/startup scripts to remove the printers, nothing seems to work.  the printers werent installed with GP so removing them from deployed printers isnt an option.  i have no issues adding our new printers with GPO, GPP it is just removing the old ones.  i am testing on a machine with admin rights and still no luck.  if i run the script direct from the computer it works fine.  i have checked GPresult and my script is under computer config, in the right OU and has a recent update time.  it just doesnt seem to remove the printers.  i have been through all options in GPP and GPO.  none of those seem to work either.  i was able to remove a printer with GPO but had to put in the IP manually.  ticking the box to delete all IP printers didnt work.  any ideas what i could be missing?
Avatar of ktaczala
ktaczala
Flag of United States of America image

Above methods?  did you forget to attach the script?
Avatar of rick81
rick81

ASKER

haha if only it was the simple.  no, script attached.
No, I mean you say you tried to remove with a script and it works when you insert IP address.  That's the script I was asking to see.

My last comment wasn't offering a solution, it was requesting the script.
Avatar of rick81

ASKER

sorry i must not have explained myself correctly.

the script is basic,  removeprinterconnection \\server\printer vbs script.  works fine run from the desktop.  

the ip removal method was using GP Preferences to remove ip printers.  this didnt seem to work either.  if i put an individual ip printer it seemed to remove but couldnt do more than one and couldnt select remove all ip printers.  it just wouldnt remove them either.  at a loss with this.
On Error Resume Next
 
strComputer = "."
   
Dim objNetwork
Set objNetwork = CreateObject("WScript.Network")
 ' ptr_server = your server, ptr_del is desired printer to delete. repeat for each printer
strPrintServer = "\\ptr_server\ptr_del"
If strPrintServer = ("\\ptr_server\ptr_del") Then
objNetwork.RemovePrinterConnection ("\\ptr_server\ptr_del")  


Is this similar to what you're using?
Here's a link with a way of deleting all network printers without having to know the individual names of the printers.
http://blogs.technet.com/b/heyscriptingguy/archive/2007/11/02/hey-scripting-guy-how-can-i-remove-all-the-network-printers-on-a-computer.aspx
Avatar of rick81

ASKER

yep the scripting isn't the issue here as they work fine run from the desktop.  the issues is why i cant remove printers with GPO/GPP or a script at startup/shutdown, logoff, logon, etc.
and the computer i am testing from has full admin rights.  its a strange one.
It's possible that the printers aren't mapped until after the script runs.
Avatar of rick81

ASKER

the printers have been manually installed though.  they are not re-mapping with a script or anything like that.  and i would have thought using GPP to remove and gpupdate/force would remove them.
'try adding this into your startup script see if they are mapped, it should write
'to a file called output.txt

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("output.txt", True)

Set colInstalledPrinters =  objWMIService.ExecQuery(“Select * from Win32_Printer”)

For Each objPrinter in colInstalledPrinters

Printer = objPrinter.name

objFile.WriteLine "    " &  Printer

next
ASKER CERTIFIED SOLUTION
Avatar of rick81
rick81

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 rick81

ASKER

resolved issue myself