[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 17166
  • Last Modified:

Logon script to delete old network printers

We recently converted to a Novell based network to Windows 2003.  We have scripts that run to set each user's network printers at logon.  However, many users still have the Novell printer queues in their printer list.  This is confusing to many of them who are used to selecting these old names when they wish to print.  Does anyone know of a script that we could run at logon that clears ALL printer connections (as opposed to just one) so that the new printer names could be set through the logon scripts that are already running without any old printer names confusing out users?

Thanks

Jason
0
MHCC
Asked:
MHCC
  • 7
  • 7
  • 5
  • +5
2 Solutions
 
fixnixCommented:
Actually, this question was addressed as a sidenote elsewhere in EE at:

http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20951042.html

In the accepted answer, it notes "Note con2prt.exe's "/f" switch which will delete all existing network printers." which is relavent to your question.
0
 
MHCCAuthor Commented:
Both of these comments suggest the use of additional programs, such as com2prt.exe, or prndrvr.vbs.  Where are these files located? Or, do I have to download them? Is there any other way to delete all printer connections without referencing an additional program?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
fixnixCommented:
I did a little digging and only found "Con2prt.exe tool is included with the Zero Administration Kit for Windows NT 4.0"

That statement was referenced from a solution for Windows 2000, but I found nothing specifically saying the NT Zero Administration Kit can be used on win2k (although apparently it can) or server 2k3 (which I can't say with certainty weather it will work on 2k3 or not...didn't find any info either way).

Sorry, but I do not know of a way to delete all printers without referening something you'd have to download separately, nor am I familiar with NetoMeter's method so I guess I'm already tapped out on this question for you :(.
0
 
fixnixCommented:
Ahh...2k3 resource kit at http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en

Which does not list Con2prt.exe but does list a "Prnadmin.dll: Printer Administration Objects"...

still searching for the specifics on doing what you want via the admin kit...not to belittle NetoMeter's suggestion...that may be all you need.

(still didn't turn up a way to delete *all* printers w/o downloading extras, either)
0
 
purplepomegraniteCommented:
prndrvr.vbs is a script that is included with WinXP - it is found in the windows\system32 folder.  The other program I'm not sure about, but would recommend sticking to the MS method anyway.

prndrvr.vbs is a visual basic script which simply calls built-in Windows routines to modify printer settings - it isn't an external program as such.
0
 
MHCCAuthor Commented:
Thanks for the help guys. I will keep trying and let you know soon.
0
 
purplepomegraniteCommented:
Heh, amazing how other's comments appear while I'm typing mine!

It is entirely possible to delete all printers via script, which is why I recommend the MS approach.
0
 
fixnixCommented:
purp:  I believe using MS's own resource kit would still be a "MS approach" in addition to using prndrvr.vbs.  (No offnese intended...just nitpicking :) )

And yes...those comments that automagically appear while I'm typing happen all the time, too!! :)

-Cheers!

0
 
fixnixCommented:
Found a solution for you if nothing worked for you yet...the original site seems to be unavailable or the link changed, but google's cache still has it:

http://64.233.187.104/search?q=cache:9-SMgGJw3cgJ:dbforums.com/arch/196/2003/2/673671+%22delete+all+printers%22+%22logon+script%22+%2B2003&hl=en&lr=lang_en
0
 
sciwriterCommented:
Why not just delete all the Netware printers entirely and just remake them in 2003?  
I mean, you can install about 30 printers per hour, just from the windows console, knowing the IP, or UNC name.
What am I missing here, "british diabase" (pun on ppg), isn't this the simplest thing to do?
(BTW I love your login, only a Au Geol. can truly appreciate it).
0
 
MHCCAuthor Commented:
Hey thanks. Well the problem isn't with deleting the printers, it is with automating it through a login script.  The reason for this is we have over 150 workstations, and I would rather not go to each station and delete them if I can avoid it.  The printers already exist in 2003.  I just like automation better than station to station.

0
 
purplepomegraniteCommented:
Hi fixnix, and yes, MS resource kit must really be MS approach!!  I'll choose my words carefully next time!  It is from NT resource kit though, and the vbs scripts have been introduced in Win2k, XP, and 2003 to aid automation without the need for executables.

Pretty much all admin tasks can now be achieved via wmi script .  I manage several networks and use wmi constantly - I don't even have to visit sites anymore except in extreme situations.  I use wmi to install, delete and modify network printers in exactly the way MHCC requires - full documentation for this is on MS Technet.

To delete the printers you need to use the prnmngr.vbs script.  Full documentation from MS is here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/prnmngr.mspx
0
 
purplepomegraniteCommented:
cscript prnmngr.vbs -x [-s RemoteComputer] [-u UserName] [-w Password]

As shown in the article referenced above, that is the command-line that will delete ALL printers from the specified computer.
0
 
sciwriterCommented:
<< The reason for this is we have over 150 workstations, and I would rather not go to each station and delete them if I can avoid it.>>

To clean up the migration, isn't it worth that effort, so there are no ghost relics lying around?
0
 
purplepomegraniteCommented:
"To clean up the migration, isn't it worth that effort, so there are no ghost relics lying around?"

Why?! Computers are here to make our lives easier!!  If I'm worried about ghost relics, I'll call a priest to perform an exorcism!
0
 
MHCCAuthor Commented:
All right, I think I will give the points to purplepomegranite because if I make a batch file that switches to the directory "C:\Winnt\system32" and then runs "cscript prnmngr.vbs -x" with NO other parameters then this seems to delete all exisitng printers successfully.  I think I will have the batch file run once at login.  However, I will have to do something different for the few computers that have a local printer attached, as I do no want to delete the local printer.  Thanks for all your help.
0
 
MHCCAuthor Commented:
Actually, on second thought I am going to split the points. I liked fixnix's solution also because it seems to only delete network printers.  

Fixnix- do you know if there is a way to run this script (with the look) that does NOT require the user to press OK every time a printer is deleted? That is what seems to be going on.  Does this happen with all loops? Or is it simply because the script is deleting printers?
0
 
MHCCAuthor Commented:
K, sorry. Disregard that last question.  If you take the "wscript.echo" out of the vbscript then it does not ask the user to OK the change.  It works beautifully, and here is the final VBscript that I will be using if anyone else ever wants to know:

set net = CreateObject ("WScript.Network")

'deletes all network printers
Set clPrinters = net.EnumPrinterConnections
For i = 0 to clPrinters.Count - 1 Step 2
clPrinters.Item(i)& " " & i+1
net.RemovePrinterConnection clPrinters.Item(i+1), true
Next

'maps new printers.
net.AddWindowsPrinterConnection "\\SERVER\MHCC_ADMIT", "Admissions"
net.AddWindowsPrinterConnection "\\SERVER\MHCC_ADMIT_STICKER", "Admissions Sticker Printer"
net.AddWindowsPrinterConnection "\\SERVER\MHCC_ER_STICKER", "ER Sticker Printer"
net.SetDefaultPrinter "\\SERVER\MHCC_ADMIT"

Wscript.Quit
0
 
purplepomegraniteCommented:
As far as prmmngr.vbs goes, that is one way to do it (and a good way as it'll be done next time the user logs on).

It can also be run from the server, e.g.

cscript prnmngr.vbs -x -s comp1 -u Administrator -w adminpw

This would delete all the printers on comp1, assuming it was switched on.

prnmngr.vbs is in fact just a script, and it is using exactly the same methods as the script fixnix linked.  You certainly should be able to change it to prevent the confirmation.
0
 
purplepomegraniteCommented:
Nice, and thanks for posting the final script.  Always useful.
0
 
MHCCAuthor Commented:
Cool. Thanks again for the info and all your help.
0
 
pmajon79Commented:
Accepted solution link non-functional.
0
 
mirchevskyCommented:
dito on that.  
0
 
ISALRWCommented:
I have found the key to removing printers via log on scripts
Add this to your scrips

rundll32 printui.dll,PrintUIEntry /dn /q /n \\Vn-srv-print\network
                                                               just change this part to your servername\ and printer name.

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 7
  • 7
  • 5
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now