Re: AddPrinterDriver return error 87 HELP!!!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Jiachuan Wang [MSFT] (jiawang_at_online.microsoft.com)
Date: 03/24/04


Date: Wed, 24 Mar 2004 10:21:25 -0800

I mean to send you this one from ScriptCenter: (previous one for installing
printer)

Install Printer Drivers

Description

Installs the printer driver for an Apple LaserWriter 8500 printer. Requires
Windows XP or Windows Server 2003.

Set objWMIService = GetObject("winmgmts:")
Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objDriver.Name = "Apple LaserWriter 8500"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
errResult = objDriver.AddPrinterDriver(objDriver)

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jiachuan Wang [MSFT]" <jiawang@online.microsoft.com> wrote in message
news:...
>
> Here's the example from ScriptCenter for "Install a Printer"
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
>     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
> objPrinter.DriverName = "HP LaserJet 4000 Series PS"
> objPrinter.PortName   = "IP_169.254.110.160"
> objPrinter.DeviceID   = "ScriptedPrinter"
> objPrinter.Location = "USA/Redmond/Building 37/Room 114"
> objPrinter.Network = True
> objPrinter.Shared = True
> objPrinter.ShareName = "ScriptedPrinter"
> objPrinter.Put_
>
> -- 
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
> "Tal." <anonymous@discussions.microsoft.com> wrote in message
> news:de6601c41177$f4513680$a001280a@phx.gbl...
> > Now the WScript.Echo showing error 200413 and then the
> > cscript come out with error 80041002 (SWbemobjctEx)
> >
> > ??
> >
> >
> > >-----Original Message-----
> > >you need to spawn the instance of printer driver class
> > before filling in
> > >properties
> > >use this
> > >set objDriver = objWMIService.Get
> > ("Win32_PrinterDriver").Spawninstance_
> > >
> > >instead of
> > >
> > > Set objDriver = objWMIService.Get("Win32_PrinterDriver")
> > >
> > >
> > >-- 
> > >Sarika Sharma [MSFT]
> > >WMI Test Engineer
> > >This posting is provided "As Is" with no warranties, and
> > confers no rights.
> > >Use of included script samples are subject to the terms
> > specified at
> > >http://www.microsoft.com/info/cpyright.htm
> > >Please do not send e-mail directly to this alias. This
> > alias is for
> > >newsgroup purposes only.
> > >
> > >
> > >
> > >
> > >
> > ><anonymous@discussions.microsoft.com> wrote in message
> > >news:11cef01c410ca$9379fca0$a401280a@phx.gbl...
> > >> I am tring to add printer driver with WMI.
> > >> It always return error 87 which is not documented
> > anywhere
> > >>
> > >> PLEASE HELP!!!
> > >>
> > >> Here is my code:
> > >>
> > >> strComputer = "."
> > >> Set objWMIService = GetObject("winmgmts:" & _
> > >>     "{impersonationLevel=impersonate}!\\" & strComputer
> > >> & "\root\cimv2")
> > >> Set objDriver = objWMIService.Get
> > ("Win32_PrinterDriver")
> > >> objDriver.Name =  "hp LaserJet 1300 PCL6"
> > >> objDriver.SupportedPlatform = "Windows NT x86"
> > >> objDriver.Version = "3"
> > >> objDriver.FilePath = "D:\1300N_PLC6"
> > >> objDriver.InfName =  "D:\1300N_PLC6\hp1300m6.inf"
> > >> intResult = objDriver.AddPrinterDriver(objDriver)
> > >> WScript.Echo intResult
> > >>
> > >
> > >
> > >.
> > >
>
>


Relevant Pages

  • Re: Page Orientation capability in Unidrv? Reverse Print direction
    ... process and set breakpoints in the Print Processor and Printer Driver. ... I can try to install your driver but I really don't have the bandwith to do ... I copied and pasted your inf file and gave it a try, ... the printer driver will install and print, ...
    (microsoft.public.development.device.drivers)
  • RE: Client Laptop install Printer to Server
    ... Thanks for using the SBS newsgroup! ... I understand that the issue to be: the printer driver ... will be installed if you connect to the SBS server box from one laptop. ... If you do need printer redirection function, please install the driver ...
    (microsoft.public.windows.server.sbs)
  • Re: Word 2007 buggy and crashes.
    ... Local printer driver is set as default. ... Running in safe mode I can print to network printer from within Word ... Safe Mode Word is working in its default install ... printer driver, macros, templates, add-ins, ...
    (microsoft.public.word.application.errors)
  • RE: Remote Web Workplace Printing with Multifunction
    ... I'm trying to install ... to print to remotely when they connect through remote desktop/RWW. ... The type of port could be an issue when trying to print, ... It would be great if HP could offer just the printer driver for cases like ...
    (microsoft.public.windows.server.sbs)
  • Re: "All fax printers are inaccessible" after Remove-then-Add Fax
    ... How do I install the Windows XP Fax ... After I lengthened the time delay, ... The Microsoft Shared Fax Driver printer driver is not installed on this ...
    (microsoft.public.windowsxp.print_fax)