Contents of Guy’s Scripting Ezine 5 – Printers
I will let you into a secret; my most difficult logon script has been to map multiple printers.
Tom, I thank you for drawing my attention to the printer script problems, and gently nudging me to investigate solutions.
Once again, I have been grappling with CGI scripts. Learning a new scripting language has been a humbling process and it has brought home the need to cover error messages with my own scripts. Now I realize that when you are in a hurry that you just want to copy and paste the scripts. However, if you wish to learn how VBscripts works, then there is no gain without pain, and that pain is deciphering error messages.
Guy Recommends: The Free IP Address Tracker (IPAT)
Calculating IP Address ranges is a black art, which many network managers solve by creating custom Excel spreadsheets. IPAT cracks this problem of allocating IP addresses in networks in two ways:
For Mr Organized there is a nifty subnet calculator, you enter the network address and the subnet mask, then IPAT works out the usable addresses and their ranges.
For Mr Lazy IPAT discovers and then displays the IP addresses of existing computers. Download the Free IP Address Tracker
The purpose of this script is to map more than one printer.
Copy the lines below, paste into notepad, save with .vbs extension example printerduo.vbs. Prerequisites: you need two network printers. If need be, create a "pretend" printer with the add printers wizard.
"Dim net" declares net as a variable. (dim print would work just as well)
set net = createobject ("wscript.network"). (This line is creating "net" and setting as a network object. Other objects would be user or computer)
net.AddWindowsPrinterConnection "\\lucy4\dotty", "Dot Matrix (AddWindowsPrinterConnection is a method telling it what do. MapNetworkDrive is another method)
Unlike variables, you cannot make up your own methods, they are built in and you just learn or collect them to use in your scripts.
Here is a reference to get more ideas, for example to the default printerhttps://computerperformance.co.uk/Logon/LogonScript_Printer.htm
Expected end of statement
Clues. The error is to be found on the 9th Line down – blank lines ARE counted, and remark lines are counted. 71st character – again including blanks. This is the area where the problem is located.
What can "Expected end of statement" mean? Some things missing? So try an extra carriage return and bingo – it works. (Actually I first tried a comma, but that did not work.)
Code 800A0401. All error codes begin with 800, so pay close attention to the last 5 characters. Search Google for "Code 800A0401" sometimes you find useful clues, often its just other people with the same problem! If a Google search cannot help then do contact me.
References for more Error messages: 0800xxxx Error Codes
See more about logon printer VBScripts