[saw huan chng] > I am beginner in Python. I have some questions on WMI Service in Python. > I was able to use properties of Class Restore in WMI, but not able to > use the method. Here is the sample code that I done, anyone can help me?
[... snip code ...] OK, I don't actually use XP (and the SystemRestore doesn't exist on 2000) but I *strongly* suggest that if you're going to do anything with WMI you (** blows own trumpet **) use this module: http://timgolden.me.uk/python/wmi.html It does some of the dirty work you'd otherwise have to do. Effectively, the answer to your question is that Method-calling in WMI is a bit of a messy process. That's why I wrote the module to cover up the messiness. Unfortunately, there are some new areas of WMI-ness in XP which I've never really used, so the module's a bit weak in these areas. Using the wmi module, you'll have to do this (effectively untested): <code> import wmi connection = wmi.connect_server (".", namespace=r"root\DEFAULT") sequence_number = 11 # # Bit of a hack; I need to improve the module here # system_restore = wmi._wmi_object (connection.Get ("SystemRestore")) system_restore.Restore (sequence_number) </code> If you really want to do it yourself, you need to do something like this: (*very* untested) <code> import win32com.client wmi_service = win32com.client.Dispatch ("WbemSripting.SWbemLocator") wbem_services = wmi_service.ConnectServer (".", r"root\DEFAULT") test_obj = wbem_services.Get ("SystemRestore") sequence_number = 11 restore_method = test_obj.Methods_ ("Restore") restore_params = restore_method.InParameters restore_params.Properties_ ("SequenceNumber").Value = sequence_number test_obj.ExecMethod_ ("Restore", restore_params) </code> Hope that helps a bit TJG ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -- http://mail.python.org/mailman/listinfo/python-list