+ Post New Thread
Results 1 to 5 of 5
Windows Thread, Printer install via vbscript in Technical; Hello I have created a vbscript by cannibalising others on the interweb to install a printer port, the driver and ...
  1. #1


    Join Date
    Sep 2009
    Posts
    574
    Thank Post
    13
    Thanked 55 Times in 34 Posts
    Rep Power
    224

    Printer install via vbscript

    Hello

    I have created a vbscript by cannibalising others on the interweb to install a printer port, the driver and then the actual printer. On some machines it works, on others i get the following error:

    Code:
    Script:     Install.vbs
    Line:       34
    Char:      1
    Error:      Generic Failure
    Code:      80041001
    Source:   SWbemObjectEx
    the vbscript looks like this:
    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    	& "{impersonationLevel=impersonate}!\\" & strComputer &"\root\cimv2")
    Set objNewPort = objWMIService.Get _
    	("Win32_TCPIPPrinterPort").SpawnInstance_
    
    objNewPort.Name = "IP_x.x.x.206"
    objNewPort.Protocol = 1
    objNewPort.HostAddress = "x.x.x.206"
    objNewPort.PortNumber = "9100"
    objNewPort.SNMPEnabled = False
    objNewPort.Put_
    
    objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
    
    Set objDriver = objWMIService.Get("Win32_PrinterDriver")
    
    objDriver.Name = "HP Color LaserJet CP3505 PCL 6"
    'objDriver.SupportedPlatform = "Windows NT x86"
    'objDriver.Version = "3"
    objInfname = "\\x.x.x.5\Apps\Printer Drivers\Konica Minolta BizHub C360\KOAZ8J__.inf"
    intResult = objDriver.AddPrinterDriver(objDriver)
    
    Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
    
    objPrinter.DriverName = "KONICA MINOLTA C360SeriesPCL"
    objPrinter.PortName   = "IP_x.x.x.206"
    objPrinter.DeviceID   = "KONICA MINOLTA C360SeriesPCL"
    objPrinter.Location = "Printer Location"
    objPrinter.Network = True
    objPrinter.Shared = False
    objPrinter.Put_
    can anyone shed any light on this problem???

    Thanks

  2. #2
    ahuxham's Avatar
    Join Date
    Apr 2008
    Posts
    1,122
    Thank Post
    76
    Thanked 138 Times in 109 Posts
    Rep Power
    31
    Copy and pasting only shows 32 lines. Hard to diagnose a problem when the script isn't intact and the associated line isn't in place

  3. #3

    Join Date
    Dec 2007
    Posts
    870
    Thank Post
    90
    Thanked 165 Times in 140 Posts
    Rep Power
    49
    I just used to use this:

    set wshnet = CreateObject("WScript.Network")
    wshnet.AddWindowsPrinterConnection "\\{printerservername}\{name of printer share 1}"
    wshnet.AddWindowsPrinterConnection "\\{printerservername}\{name of printer share 2}"
    WshNet.SetDefaultPrinter "\\{printerservername}\{name of default printer share}"




    I now use Group Policy Preferences to deploy and assign printers.

    Hope this helps

  4. #4


    Join Date
    Sep 2009
    Posts
    574
    Thank Post
    13
    Thanked 55 Times in 34 Posts
    Rep Power
    224
    Whoops, sorry think that's my fault. Deleted what i thought were uneeded blank lines:

    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    	& "{impersonationLevel=impersonate}!\\" & strComputer &"\root\cimv2")
    Set objNewPort = objWMIService.Get _
    	("Win32_TCPIPPrinterPort").SpawnInstance_
    
    objNewPort.Name = "IP_x.x.x.206"
    objNewPort.Protocol = 1
    objNewPort.HostAddress = "x.x.x.206"
    objNewPort.PortNumber = "9100"
    objNewPort.SNMPEnabled = False
    objNewPort.Put_
    
    
    objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
    
    Set objDriver = objWMIService.Get("Win32_PrinterDriver")
    
    objDriver.Name = "KONICA MINOLTA C360SeriesPCL"
    'objDriver.SupportedPlatform = "Windows NT x86"
    'objDriver.Version = "3"
    objInfname = "\\x.x.x.5\Apps\Printer Drivers\Konica Minolta BizHub C360\KOAZ8J__.inf"
    intResult = objDriver.AddPrinterDriver(objDriver)
    
    
    Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
    
    objPrinter.DriverName = "KONICA MINOLTA C360SeriesPCL"
    objPrinter.PortName   = "IP_x.x.x.206"
    objPrinter.DeviceID   = "KONICA MINOLTA C360SeriesPCL"
    objPrinter.Location = "Printer Location"
    objPrinter.Network = True
    objPrinter.Shared = False
    objPrinter.Put_
    With regards to MYK-IT: I can't use that method as we don't use a print server (not my decision!!!) Thanks anyway.

  5. #5


    Join Date
    Sep 2009
    Posts
    574
    Thank Post
    13
    Thanked 55 Times in 34 Posts
    Rep Power
    224
    Admins please mark as solved if possible. It turns out that some versions of XP (not sure which) don't like the objPrinter.Put_ at the end of the script. putting a comment in at the end appears to resolve it.


SHARE:
+ Post New Thread

Similar Threads

  1. Printer install!
    By MrPstv in forum Hardware
    Replies: 4
    Last Post: 17th September 2008, 10:40 AM
  2. Install printer without the printer.
    By kennysarmy in forum Hardware
    Replies: 9
    Last Post: 23rd January 2008, 11:42 AM
  3. Can't install printer
    By tscnmuk in forum Windows
    Replies: 3
    Last Post: 10th January 2008, 12:19 PM
  4. R2 Printer Manager Failed to install
    By apeo in forum Windows
    Replies: 6
    Last Post: 4th July 2007, 06:57 AM
  5. Printer vbscript ?
    By mac_shinobi in forum Scripts
    Replies: 1
    Last Post: 14th September 2005, 08:21 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •