Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Sorry Logon Printer Script.... again


Recommended Posts

Posted

Hi I have had a lot of problems recently at one of the primary schools i support and i have got them it pretty much all working again now apart from one thing - the printers!!! Sorry i know its been covered before but my brain is fried and i cant think of where to start.

 

All i need is a simple script to delete any existing printers, local/network then add one shared printer from the server. It is just an ICT suite so it doesnt need to look at locations.

 

I dont mind what language its in. batch/vbs/autoIT i dont mind it just needs to run as a logon script.

 

I would be eternally grateful!

Posted
Set WshNetwork = CreateObject("WScript.Network")

rem ** This will delete existing printers **
On Error Resume Next
Set oPrinters = WshNetwork.EnumPrinterConnections
For i = 1 to oPrinters.Count - 1 Step 2
WshNetwork.RemovePrinterConnection oPrinters.Item(i)
Next

rem ** Adds printers - new line for each printer **
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection "\\SRVNAME\PTRSHARE"
WshNetwork.AddWindowsPrinterConnection "\\SRVNAME\PTRSHARE2"

rem ** Setup default printer **
WshNetwork.SetDefaultPrinter "\\SRVNAME\PTRSHARE" 

  • Thanks 1
Posted
You may find that some printers will refuse to be deleted because they were added to the local system some other way. There's some discussion about it in various threads but just a note so you don't think you're losing your mind.

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...