[python-win32] Exception: object has no attribute 'Win32_Process'
Tim Golden
mail at timgolden.me.uk
Fri Jan 8 18:37:04 CET 2010
On 04/01/2010 17:06, Wade Dyck wrote:
[...]
> 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))
As a tiny aside here, I suspect that: (a) you don't need the cmd.exe
to run xcopy: it's actually an executable; and (b) you might to
double-quote the %s params to xcopy. Neither of these things are
going to be causing the error you report, but just to be helpful...
>
> 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.
It is peculiar, assuming you are running exactly the same code, only
with AD setting switched as you describe. ie there's no possibility
that self.c has become something other than a WMI instance?
I'll try to look it at it when I get back to work (which won't be
till Monday now; I'm just back from a week away). If you manage
to fix it in the meantime, please do post back.
TJG
More information about the python-win32
mailing list