[python-win32] Invalid method parameters with UnjoinDomainOrWorkgroup
Tim Golden
mail at timgolden.me.uk
Wed Dec 23 10:24:31 CET 2009
Tim Golden wrote:
> Gowtham wrote:
>> I am trying to unjoin a machine from the domain and attempted with the
>> following code
>>
>>
>> import wmi
>> wm = wmi.WMI()
>> wm.Win32_ComputerSystem.UnjoinDomainOrWorkgroup(2, 'ADMINPASSWORD',
>> 'DOMAIN\ADMINUSER')
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> File "C:\Python24\Lib\site-packages\wmi.py", line 396, in __call__
>> handle_com_error (error_info)
>> File "C:\Python24\Lib\site-packages\wmi.py", line 189, in handle_com_error
>> raise x_wmi, "\n".join (exception_string)
>> wmi.x_wmi: -0x7ffdfff7 - Exception occurred.
>> Error in: SWbemObjectEx
>> -0x7ffbefd1 - Invalid method Parameter(s)
>>
>> I dont understand why its calling these Invalid method parameters. All that
>> it wants is an (Int, Str, Str) when using thru Python otherwise it is (Str,
>> Str, int) as described here.
>> http://msdn.microsoft.com/en-us/library/aa393942(VS.85).aspx
>
> Just to cut the small Gordian knot, you can pass the parameters
> by name rather than by position:
> (as long as you're using a reasonably recent version of the
> wmi module, >= 1.3.2 IIRC).
>
> w.Win32_ComputerSystem.UnjoinDomainOrWorkgroup (
> UserName="blah",
> Password="blah",
> FUnjoinOptions=0
> )
Sorry; of course that example (and your code above) should
be using a Win32_ComputerSystem *instance*, not the class
itself:
for sys in c.Win32_ComputerSystem ():
sys.UnjoinDomainOrWorkgroup (
...
)
TJG
More information about the python-win32
mailing list