Jump to content

Recommended Posts

Posted

Ok, I need a script that will remove all printers from a workstation, EXCEPT where that printer is connected via LPT or USB.

 

Basically, all of our network printers are connected directly to the network and so are installed on the PC as Local printers using a Standard TCP/IP Port. I now need to remove them as I need to do a bulk update of drivers and printer types (so many changes!). I've tried variations of the scripts I've found on here, but none seem to actually work. Anyone know how to do what I'm after?

 

And no, I can't run them all through a server or use logon scripts (don't you just love managed services!).

 

Cheers all,

 

Rob Cowan.

Posted

I will assume you have looked ar Rics script.

I think with your setup its this line that needs changing

 

For i = 0 to oPrinters.Count - 1 Step 2

 

Its something to do with the step that handles those direct printers because when I log onto the print server my log in script does not delete all the printers. Try it without the step 2 or look at con2prt.

Posted

Why not just disconnect all printers and then reconnect the relevant ones depending on the computer and its location? Might make things easier in the long run.

 

Rob.

Posted

Try this:

 

on error resume next
Set shell= WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
dim Counter, PrinterPath

'Remove All Network Printers.

Set oPrinters = WshNetwork.EnumPrinterConnections
FOR Counter = 0 to oPrinters.Count - 1
IF mid(oPrinters.Item(Counter), 1, 2) = "\\" THEN
	PrinterPath = oPrinters.Item(Counter)
	WshNetwork.RemovePrinterConnection PrinterPath, True, True
End If
Next

Posted

Ok. I've found a solution of sorts. I'm now using the Prnmngr.vbs script that appears to come with Windows XP.

 

@Chris: Cheers for the pointer. I might look down that route if I ever get more time/vbscript skills.

 

@_Rob_: Was trying to avoid this but I think it's going to have to be the way.

 

@apeo: Unfortunately, I've already tried that script. I'm not 100% sure, but I think it's actually looking for the beginnings of a UNC path in the printer settings, which these won't have as they're running direct to an IP address.

 

Either way, thanks for the responses. And if anyone's interested in it, you can find out more about Prnmngr.vbs here

Posted
Oh right you have printers installed locally using IP. Yes your are right is is looking for the first 2 chars of unc path so in your case i probably would have deleted all printers that ltp: or usb: ie if not ltp: then but as you have alredy foud a way it doesnt really matter :)
Posted

Man what was up with my last post.. loads of typos :oops:

 

@Ric_: Yup, the section on your script that deletes printers did what i suggested. :)

Posted
@Ric: Nope, tried that one too. It's entirely possible that these PCs are just doing this to annoy me. Also, I'm not running the script as a logon script. It's actually being punted out using the Ghost Console which then executes the command on each system locally (or that's the theory anyway!). I would love to use it as a logon script, but I have no control over those.
Posted
Just checked it out and i think its case sensitive so lpt should be LPT. Oh thanks for letting us know about the Prnmngr.vbs, may come it handy at some point in the future.
Posted
What context does your script get run as? Logon scripts run with elevated priviledges and if that doesn't work, run it as a startup script cos then it will run as SYSTEM.
Posted

And the suggestions just keep coming! :D

 

Well, I've cracked it using prnmngr.vbs & I'll just add back any LPT or USB connected printers manually (there's only a few anyway). On top of that, I've finally got my head round push installs using Lexmark's scripting system so I should soon be able to remove all of our extraneous printers & start again with just the required printers on each workstation.

 

Although knowing my luck, it'll all go south when I try to actually run it!

 

Cheers,

 

RobC.

  • 1 month later...
Posted
I'm stuck on is how to make so that the script will only run if the user logged on is either kid1, kid2 or kid3.
Posted

sorry... usernames.

 

There is apparently 3 kids who keep printing out reams but deny they are doing it and claim its other using their name. So I've been asked if they can be disabled from printing.

Posted
what you could do is to have a the script check username and for those users not to install printers. Gimme a sec and i will see if i can come up with an example.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...