We help IT Professionals succeed at work.
Get Started

VBScript Error Win 7 (scriptname.vbs(28, 1) SWbe mObjectEx:Generic failure)

909 Views
Last Modified: 2012-05-12
PART 1 ------  Here is a Script that I use to install printers on windows Xp machines - IF I run the script on the windows 7 Machine I get the error (scriptname.vbs(28, 1) SWbe mObjectEx:Generic failure), If i use this script and run it from the command line I get the same message. If i run the script a few times the printer will eventually install. for windows 7 Machines. What do I Need to change ????

Part 2 - Secondly I would like to have users run this script. How do i change the script to run as domain\user    password with the credentials been seen?

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objNewPort = objWMIService.get("Win32_TCPIPPrinterPort").SpawnInstance_
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objWMIService.Security_.Privileges.AddAsString "SeLoadDriverPrivilege", True
Set objDriver = objWMIService.Get("Win32_PrinterDriver")
objDriver.Name = "Canon iR5070 PCL6"
objDriver.SupportedPlatform = "Windows NT x86"
objDriver.Version = "3"
objDriver.FilePath = "K:\\DRIVERS\\Canon Copier\\pcl6"
objDriver.Infname = "K:\\DRIVERS\\Canon Copier\\pcl6\\P62KUSAL.INF"
intResult = objDriver.AddPrinterDriver(objDriver)

'Installs Printer Port
objNewPort.Name = "10.16.11.185"
objNewPort.Protocol = 1
objNewPort.HostAddress = "10.16.11.185"
objNewPort.PortNumber = 9100
objNewPort.SNMPEnabled = True
objNewPort.Put_

'Install Printer
objPrinter.DriverName = "Canon iR5070 PCL6"
objPrinter.PortName = "10.16.11.185"
objPrinter.DeviceID = "Canon iR5070 PCL6"
objPrinter.Location = "E.Hart 99 East River Dr 6th Flr"
objPrinter.Network = True
objPrinter.Put_
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE