Question Locked

Properly Mapping Printers through Logon Script?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi all,

Due to the way the physical layout of our building is combined with the hardware on hand, I am forced to share printers from workstations. I realize this is not optimal and network printers installed on a print server would be the correct way to do things...

This is my current *ugly* logon vbs script:

Set wshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\TB-003\HPLaserJ"
WshNetwork.AddwindowsPrinterConnection PrinterPath, PrinterDriver

Set wshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\TBLAZE1\ReadingRoomLaser"
WshNetwork.AddwindowsPrinterConnection PrinterPath, PrinterDriver

Set wshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\jansson3\JanssonLaser"
WshNetwork.AddwindowsPrinterConnection PrinterPath, PrinterDriver

Set wshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\server2\OceCopier"
WshNetwork.AddwindowsPrinterConnection PrinterPath, PrinterDriver

Set wshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\TBLAZE12\GreavesL"
WshNetwork.AddwindowsPrinterConnection PrinterPath, PrinterDriver

Set wshNetwork = CreateObject("WScript.Network")
PrinterPath = "\\MONTE4\LJ2420-Monte"
WshNetwork.AddwindowsPrinterConnection PrinterPath, PrinterDriver

My question is how can I catch errors when a printer will not map (due to the machine being turned off, etc), but continue the script? Currently if one printer is unavailable, the script fails and none of the printers are mapped.

Thanks in advance!
Chris

5 replies

by ---tk---

On Error Resume Next
Set objNetwork = CreateObject("WScript.Network")

objNetwork.RemovePrinterConnection "\\grand\HPLaserJ", "True"
objNetwork.RemovePrinterConnection "\\TBLAZE1\ReadingRoomLaser", "True"
objNetwork.RemovePrinterConnection "\\jansson3\JanssonLaser", "True"
objNetwork.RemovePrinterConnection "\\server2\OceCopier", "True"
objNetwork.RemovePrinterConnection "\\TBLAZE12\GreavesL", "True"
objNetwork.RemovePrinterConnection "\\MONTE4\LJ2420-Monte", "True"

objNetwork.AddWindowsPrinterConnection "\\grand\HPLaserJ"
objNetwork.AddWindowsPrinterConnection "\\TBLAZE1\ReadingRoomLaser"
objNetwork.AddWindowsPrinterConnection "\\jansson3\JanssonLaser"
objNetwork.AddWindowsPrinterConnection "\\server2\OceCopier"
objNetwork.AddWindowsPrinterConnection "\\TBLAZE12\GreavesL"
objNetwork.AddWindowsPrinterConnection "\\MONTE4\LJ2420-Monte"
objNetwork.SetDefaultPrinter "what every you want"

WScript.Quit

Added: this might work for you, a friend of mine made it (cant take credit for it), I moded it to suite your needs.

by csmeraglinolo

I will give this a shot in the AM. Thanks so much for taking the time to help out!!

by csmeraglinolo

Thanks again so much for your contribution! Have a great day.

Chris

This discussion is closed to new replies.