Jump to content

Recommended Posts

Posted

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)

 

Or:

 

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 !

 

Robin.

 

 

--------------------------

 

strComputer = "."

 

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

 

Set colInstalledPrinters = objWMIService.ExecQuery _

("Select * From Win32_Printer Where Network = True")

 

For Each objPrinter in colInstalledPrinters

objPrinter.Delete_

Next

 

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

WScript.Quit

End Select

 

oNetwork.AddWindowsPrinterConnection sPrintPath

oNetwork.SetDefaultPrinter sPrintPath

 

-----------------------

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...