[python-win32] rename computer

cd christophedeze at wanadoo.fr
Mon Dec 19 15:55:01 CET 2011


thanks genius it works !!



> Message du 19/12/11 15:34
> De : "Tim Golden" 
> A : python-win32 at python.org
> Copie à : 
> Objet : Re: [python-win32] rename computer
> 
> On 19/12/2011 14:20, cd wrote:
> > import wmi
> > c = wmi.WMI().Win32_ComputerSystem
> > computer = c()[0]
> > for propertyName in sorted( list( c.properties ) ):
> > if propertyName == 'Name':
> > print setattr( computer, propertyName, 'newname' )
> 
> Ah.
> 
> I'm afraid, good as WMI is, it's not that good. You need to
> invoke the right method on the Win32_ComputerSystem instance.
> 
> The appropriate method is referenced here:
> 
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa393056%28v=vs.85%29.aspx
> 
> 
> There are some examples here:
> 
> http://msdn.microsoft.com/en-us/library/windows/desktop/aa394586%28v=vs.85%29.aspx
> 
> 
> and the (definitely untested) Python equivalent is something
> like this:
> 
> 
> import wmi
> 
> c = wmi.WMI ()
> for system in c.Win32_ComputerSystem ():
> system.Rename ("NEW-NAME", "TIM", "PASSWORD")
> 
> 
> 
> TJG
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
> 


More information about the python-win32 mailing list