Hi All,
I have a python script that retrieves the user profile path from the
registry using wmi. I am doing this way as win32net.NetUserGetInfo could not
somehow find the domain user. Here the code snippet-
def GetProfilePath(username):
pythoncom.CoInitialize()
try:
reg = wmi.WMI(find_classes=False, namespace='default').StdRegProv
try:
unused_result, profilepath = reg.GetExpandedStringValue(
hDefKey=_winreg.HKEY_LOCAL_MACHINE,
sSubKeyName=('%s\\%s' % (ProfileSettings.PROFILES_KEY,
ProfileSettings.ObtainSid(username))),
sValueName='ProfileImagePath')
except WindowsError:
raise NoProfileInfoError(
'The user %s has no Profile Path defined in the registry.' %
username)
finally:
pythoncom.CoUninitialize()
return profilepath
I am using pythoncom as this request would be able to run from a thread
instead from the main thread.
This works fine on most of the XP machines but some XP machines throw up
this exception-
File "wmi.pyc", line 1190, in connect
File "wmi.pyc", line 189, in handle_com_error
x_wmi: -0x7ffbeffe - OLE error 0x80041002
I see that 0x80041002 is Object not found error but why is wmi not being
able to find the object and what could be an alternative?
Any tips, appreciated.
Gowtham N
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32