473,396 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

exec method WMI

Hi, I'm trying to use the AddPrinterDriver method of
Win32_PrinterDriver to create a new..... print driver. I can't get my
head round how I need to do this. So far I have

import win32com.client
WBEM =
win32com.client.GetObject(r"winmgmts:{impersonatio nLevel=impersonate}!\\"
+ "." + r"\root\cimv2")
WBEM.Security_.Privileges.AddAsString("SeLoadDrive rPrivilege")
drv = WBEM.Get("Win32_PrinterDriver").SpawnInstance_()
drv.Properties_('Name').Value = "Marcs Printer 2550"
drv.Properties_('SupportedPlatform').Value = "Windows NT x86"
drv.Properties_('Version').Value = "3"
drv.Properties_('DriverPath').Value = 'C:\\test\\HPZPP034.DLL'
drv.Properties_('InfName').Value = 'C:\\test\\hpc2550d.inf'
method = drv.Methods_('AddPrinterDriver')
InParms = method.InParameters
InParms.Properties_.Item('DriverInfo').Value = drv
drv.ExecMethod_('AddPrinterDriver',InParms)

I'm using spawninstance to create a new object and then editing the
properties of it. I'm then setting the InParameters for the method to
be the new object. When executing the method I get SWbemObjectEx
object not found.

I think I am not setting the DriverInfo correctly, should it be an
object? The MSDN site doesn't say what DriverInfo should be.

Any help would be grand.

Thanks, MW.

Jul 21 '05 #1
2 4254
You probably need to remove the SpawnInstance_() call.
An abstract WMI class as returned by WBEM.Get should work
for the DriverInfo parm, since the concrete Win32_PrinterDriver
instance is what the AddPrinterDriver call is trying to create.

hth
Roger

<fu**********@yahoo.co.uk> wrote in message news:11*********************@g44g2000cwa.googlegro ups.com...
Hi, I'm trying to use the AddPrinterDriver method of
Win32_PrinterDriver to create a new..... print driver. I can't get my
head round how I need to do this. So far I have

import win32com.client
WBEM =
win32com.client.GetObject(r"winmgmts:{impersonatio nLevel=impersonate}!\\"
+ "." + r"\root\cimv2")
WBEM.Security_.Privileges.AddAsString("SeLoadDrive rPrivilege")
drv = WBEM.Get("Win32_PrinterDriver").SpawnInstance_()
drv.Properties_('Name').Value = "Marcs Printer 2550"
drv.Properties_('SupportedPlatform').Value = "Windows NT x86"
drv.Properties_('Version').Value = "3"
drv.Properties_('DriverPath').Value = 'C:\\test\\HPZPP034.DLL'
drv.Properties_('InfName').Value = 'C:\\test\\hpc2550d.inf'
method = drv.Methods_('AddPrinterDriver')
InParms = method.InParameters
InParms.Properties_.Item('DriverInfo').Value = drv
drv.ExecMethod_('AddPrinterDriver',InParms)

I'm using spawninstance to create a new object and then editing the
properties of it. I'm then setting the InParameters for the method to
be the new object. When executing the method I get SWbemObjectEx
object not found.

I think I am not setting the DriverInfo correctly, should it be an
object? The MSDN site doesn't say what DriverInfo should be.

Any help would be grand.

Thanks, MW.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 21 '05 #2
Got it working, removed spawninstance and the driver path should have
been "C:\\test\\"

Cheers for your help Roger.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hal Vaughan | last post by:
I have a script used to find and run Java on a Windows system.  It worked fine on original tests (on a Windows XP system).  It's now running on a Windows 2000 (sp3) system, and it won't work -- the...
0
by: Avnish Midha | last post by:
Does the Runtime.exec() method support parameters from non-native locales i.e. does it really support the entire unicode range of characters in the parameters. I am trying ot invoke a C++...
3
by: mirko | last post by:
can anyone resolve my problem? Runtime.getRuntime().exec("run.bat") it does not start the program in windows??why ?it only starts the *.exe files
1
by: laredotornado | last post by:
Hello, My hosting company does not support the PHP mcrypt functions. Instead, they recomend using the command line, /usr/local/bin/mcrypt utility via PHP's exec method. Sadly, they do not provide...
5
by: jerry051 | last post by:
I invoke a method by reflection, when this method's parameters is simple type like int or string,the invoking is correct and secceed. But when the parameters is ArrayList type, debuger tips me that...
4
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
2
by: Uldis Bojars | last post by:
Hi All, I have encountered problems with JS RegExp.exec() and can't find what is the problem. Could you help me? formRequest is a function that extracts some information from XMLHTTPRequest...
21
by: John Henry | last post by:
Hi list, I have a need to create class methods on the fly. For example, if I do: class Dummy: def __init__(self): exec '''def method_dynamic(self):\n\treturn self.method_static("it's...
2
by: Rafael Giannetti Viotti | last post by:
Hi, I am working with the subprocess.py module in Python 2.4.4 and I am confused about it's functionality. It uses the standard pipe-fork-exec method to start a subprocess: # create pipes ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.