Example of adding printers using WScript
This example was contributed by Pierre from RTIC EPL RENNES LE RHEU CFPPA RENNES-LE RHEU / CPSA COMBOURG.
This script is a variation on “Option 1″ listed under Automating printer management in a school, university or education environment but uses a Visual Basic case statement to select the appropriate printers. Again this script takes advantage of a consistent convention assigned to workstation network names. The script uses the first three letters from the computer’s name to determine physical location.
Dim objNet Dim ComputerText On Error Resume Next Set objNet = CreateObject("Wscript.Network") 'our computers' name are for example : location1pc1, location1pc2, location2pc1 etc... with 3 first letters unique 'get the 3 first letters = pc location ComputerText = left(objNet.ComputerName,3) select case ComputerText case "cdr" objNet.AddWindowsPrinterConnection "\\server\printer1" objNet.AddWindowsPrinterConnection "\\server\printer2" 'set the default printer objNet.SetDefaultPrinter "\\server\printer1" case "sip" objNet.AddWindowsPrinterConnection "\\server\printer1" objNet.AddWindowsPrinterConnection "\\server\printer3" objNet.SetDefaultPrinter "server\printer3" case else objNet.AddWindowsPrinterConnection "\\server\printer4" End select Set objNet = Nothing
PaperCut Software would like to thank Pierre for providing this example.
Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.