Hi Guys & Girls,

Iíve been asked to rectify a script related problem and was wondering if anyone else had experienced similar.

The usual story; the script has been running without problem for months. Some upgrade work has been done on the (school) network and now it has stopped working.

No changes have been made to the script.
All servers/paths/printers/shares referenced by the script are available.

Script now throws random errors and does not execute ie:

Line: 9
Char: 1
Error: 0x80041001
Source: (null)


Line: 10
Char: 5
Error: 0x80041002
Source: SWbemObjectEx

(same script both times)

A Sample of the script is below. In essence the first part strips out all network printers, and the second part adds network printers. This is done as a user moves from room to room and different printers become available.

Any ideas why the script does not run, syntax seems fine, but maybe itís not? - and the knowledge that is has been running (apparently) fine for months just confuses matters further!

Thanks !



strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * From Win32_Printer Where Network = True")

For Each objPrinter in colInstalledPrinters

Dim oNetwork, sPrintPath, sShort
Set oNetwork = CreateObject("WScript.Network")
sShort = Left (oNetwork.ComputerName, 4)

Select Case sShort

Case "204A"
sPrintPath = "\\support\LaserJet -204A-"
Case "204B"
sPrintPath = "\\support\Laserjet -204B-"
Case "204C"
sPrintPath = "\\support\LaserJet -204C-"
Case "64_A"
sPrintPath = "\\support\Laserjet -64A-"

Case Else
End Select

oNetwork.AddWindowsPrinterConnection sPrintPath
oNetwork.SetDefaultPrinter sPrintPath