Question

Locked

Properly Mapping Printers through Logon Script?

By csmeraglinolo ·
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

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Might work for you....

by ---TK--- In reply to Properly Mapping Printers ...

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.

Collapse -

Thanks!

by csmeraglinolo In reply to Might work for you....

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

Collapse -

Worked Perfectly!

by csmeraglinolo In reply to Might work for you....

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

Chris

Collapse -

good to hear :)

by ---TK--- In reply to Worked Perfectly!

best of luck!

Back to Networks Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums