Troubleshooting Code 80020009 - There is no printer called:
Introduction to Code Error 80020009
This
error code, 80020009 usually occurs when you execute a VBScript. You are
probably using a
WScript method called SetDefaultPrinter.
The Symptoms you get
The script does not set the default printer as you would have hoped. Instead, you get an Windows Script Host error message, such as the diagram on the right.
The probable scenario is that you are trying to create a Windows logon script.
The Cause of Code 80020009
The problem is that you need to map the printer FIRST, only then can you set it as the
default. Note that Source: WSHNetwork.SetDefaultPrinter gives a valuable clue. Also check the line number of the error (Line: 4).
The Solutions
Include an extra method
AddWindowsPrinterConnection in your script. Look for clues
particularly the Line: number and check the Char: references. In the
case of runtime errors, you can use this work around. Add this line: On
Error Resume Next. However it is much better to try and cure the
problem, then just use a work-around.
Example of a Code Error 80020009 Script
Part 1
Remember to add the SetDefaultPrinter command after you have first made
the printer connection with this code:
' VBScript.
Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\ServerName\PrinterName"
Below is a completed example, however remember that I do not know the name
of your server or printer share, so substitute \\ ServerName for the name of
a real server.
Part 2
' VBScript.
Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\ServerName\PrinterName"
Set net =
CreateObject("WScript.Network")
net.SetDefaultPrinter "\\ServerName\PrinterName"
Try
a different solution, download SolarWinds ipMonitor
Here is my thinking,
ipMonitor will give you valuable data about your network and servers.
This extra information just may unlock the solution to your error code.
One more thing, sometimes when troubleshooting you go around in circles;
therefore if you try a different, but related approach, you may just crack the
problem.
Free Download
of SolarWinds ipMonitor
Their topics and material are ideal for getting you started with VBScript. The
videos are easy to follow and you can control the pace. Try their free demo material and then see if you want to buy the full package.
See more about VB Script Training CD.
The extra features you get in your eBook
include, more pages full of detailed examples. Also, ten 'how to...'
sections, with screen shots showing which menus to use. Go for Guy's
eBook - and get a printable version with copy enabled and no expiry date.