[python-win32] Exception: object has no attribute 'Win32_Process'
Wade Dyck
wade.dyck at gmail.com
Mon Jan 4 18:06:20 CET 2010
I create a wmi connection to a server in a separate domain from where the
script is running like this:
remote = wmi.connect_server(server=server, user=r"%s\%s" % (domain,
user),
password=password, impersonation_level="impersonate")
self.c = wmi.WMI(wmi=remote)
I then successfully run a few Win32_Process.create() commands (which fail if
the initial connection above uses impersonation_level="delegate"). Next I
use adsi to trust the server for delegation:
computer.Put('userAccountControl', value)
computer.Setinfo()
At this point I want to use Win32_Process.create() to xcopy some files from
a third server, so I switch to delegation since impersonate won't allow
access to network resources:
remote = wmi.connect_server(server=self.server, user=r"%s\%s"
% (self.domain, self.user), password=self.password,
impersonation_level="delegate")
self.c = wmi.WMI(wmi=remote)
But then when I try to create the process using:
pid, res = self.c.Win32_Process.Create('cmd.exe /c xcopy %s %s \
/s /e /i /y /c /q' % (src, dest))
I get the following exception:
AttributeError: '<win32com.gen_py.Microsoft WMI Scripting V1.2
Library.ISWbemSer
vices instance at 0x12790040>' object has no attribute 'Win32_Process'
However, this works fine if I don't set the userAccountControl attribute
above using adsi. It also seems specific to actually setting the attribute,
as the code is always using adsi to get DNs and the current value of
userAccountControl.
Am I doing something wrong, or does anyone have suggestions on what to try
next?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100104/887f99ae/attachment.htm>
More information about the python-win32
mailing list