Discussion:
error 87 on wmi add printer driver script
(too old to reply)
t***@gmail.com
2005-08-03 21:51:44 UTC
Permalink
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege",
True

Set objDriver = objWMIService.Get("Win32_PrinterDriver")

objDriver.Name = "HP Color LaserJet 4600 PCL 6"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriverPath = "\\tmco\replication\TMCO\IT\PRINTERS\clj4600\"
objInfname = "\\tmco\replication\TMCO\IT\PRINTERS\clj4600\hp4600p6.inf"
intResult = objDriver.AddPrinterDriver(objDriver)
wScript.Echo intResult

I get a pop up of 87. Anyone know what's wrong? I get the same error
if I have the driver path and inf file on the c: drive and make the
necessary changes. Thanks.
t***@gmail.com
2005-08-03 21:55:41 UTC
Permalink
os is windows xp sp2. sorry i forgot that.
t***@gmail.com
2005-08-08 21:45:28 UTC
Permalink
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
t***@gmail.com
2005-08-09 19:10:26 UTC
Permalink
Ok, here's the deal. Apparently the Script from the M$ script center
is so FUBAR it's not even believable. I found another post where
someon was converting a correctly functioning script to C and found the
errors. here's the working script

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

set objDriver = objWMIService.Get("Win32_PrinterDriver")


objDriver.Name = "HP Color LaserJet 4600 PCL 6"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = "z:\\TMCO\\IT\\PRINTERS\\clj4600\\"
objDriver.Infname = "z:\\TMCO\\IT\\PRINTERS\\clj4600\\hp4600p6.inf"
intResult = objDriver.AddPrinterDriver(objDriver)
wScript.Echo intResult

Here are the fixes:

you had to have objDriver.FilePath instead of objDriverPath
you had to have objDriver.InfName instead of objInfname
you had to have double \\ instead of single \ in the directory listings
for the path and inf file. hope this helps other people.

Loading...