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"
Guy
Recommends: WMI Monitor and Its Free!
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft operating systems. Fortunately, Solarwinds
have created the
WMI Monitor so that you can examine these gems of
performance information for free. Take the guess work out of which
WMI counters to use for applications like Microsoft Active Directory,
SQL or Exchange Server.
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.
The Engineer's Toolset v10 provides a comprehensive console of utilities
for troubleshooting computer problems.
There are so many good gadgets, it's like having free rein of a
sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.
Download your copy of the Engineer's Toolset v 10