Link to home
Start Free TrialLog in
Avatar of mkllpit
mkllpitFlag for United States of America

asked on

VBS to add a network printer and make it the default

Can someone please tell me if this code looks good? It works but I wanted to make usre that there wasnt a better way to write it. Thank you.

Option Explicit
Dim objNetwork, strUNCPrinter
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection "\\printserver\printer"
strUNCPrinter = "\\printserver\printer"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.AddWindowsPrinterConnection strUNCPrinter
objNetwork.SetDefaultPrinter strUNCPrinter
WScript.Quit

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of prashanthd
prashanthd
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial