objPrinter.Put_

Posted: 01-30-2009, 12:38 PM

I'm posting this here as it seems to be the right place. The printer is meant
to be shared and installed via IP, and I couldn't find anywhere better to
post this....

Hello, I'm new to WSH programming, and I got a lil' problem that I can't seem
to fix at all.

I'm trying to make a scritp to install a printer via IP on the computer
(trying to do this, to upgrade it later to install multiple printers instead
of just one... if someone got a tutorial on this second part too, I'd be
really happy if you link it to me please).

The problem is... Here is the script: (I'm running this on Windows Vista)

' Script Start

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "Xerox WorkCentre 7665 rev2 PCL6"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.DriverPath = "C:\Teste\Driver WC7665\xpdprint.dll"
objDriver.Infname = "C:\Teste\Driver WC7665\XLX75XL.inf"
intResult = objDriver.AddPrinterDriver(objDriver)

Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_

objPrinter.DriverName = "IMPAPEX###"
objPrinter.PortName = "IP_10.0.1.72"
objPrinter.DeviceID = "Xerox WorkCentre 7665"
objPrinter.Location = "Location of printer"
objPrinter.Network = True
objPrinter.Shared = True
objPrinter.Put_

Wscript.Echo "Instalado!"
WScript.Quit

' Script Ends

If I run the script, I get this error:

Line: 23
Charact: 1
Error: Generic failure
Code: 80041001
Origem: SWbemObjectEx

That line is the objPrinter.Put_ command... ALL scripts I tried were crushed
on that line...

The printer port is already created, the path is correct, I'm doing this
logged as Admin so I have all permissions, I've tried disabling Drivers
signature (it was suggested by someone else) and it didn't work, I have tried
many things, with no progress.

Does anyone around knows what I could do to make it work?
I can't seem to find anything about this error, like a solid solution for it.

Thanks a lot in advance,

Alexandre Taitson Moreira

objPrinter.Put_


Responses to "objPrinter.Put_"

 
LinkBack Thread Tools Display Modes
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump