Hello, I’m trying to edit the BCD (Boot Configuration Data) using WMI in Python:
>>> import sys >>> import win32com.client >>> >>> def call(object, name, *args): ... method = object.Methods_(name) ... params = method.InParameters ... for param, arg in zip(params.Properties_, args): ... param.Value = arg ... result = object.ExecMethod_(name, params) ... return [param.Value for param in result.Properties_] ... >>> objBCD = >>> win32com.client.GetObject("winmgmts:{impersonationlevel=Impersonate,(Backup,Restore)}!root/wmi:BcdStore") >>> success, objBcdStore = call(objBCD, "OpenStore", "") >>> if not success: ... sys.exit(1) ... >>> del objBCD >>> objWBM, success = call(objBcdStore, "OpenObject", >>> "{9dea862c-5cdd-4e70-acc1-f32b344d4795}") >>> if not success: ... sys.exit(1) ... >>> success, = call(objWBM, "SetIntegerElement", 0x25000004, 5) >>> if not success: ... sys.exit(1) ... >>> objElement, success = call(objWBM, "GetElement", 0x25000004) >>> if not success: ... sys.exit(1) ... >>> print(objElement.Properties_("Integer").Value) This code has no effect (it does not change the value of element "0x25000004"), although the equivalent in VB works as expected: >>> dim objBCD >>> dim objBCDStore >>> dim objWBM >>> dim objElement >>> >>> set objBCD = >>> GetObject("winmgmts:{impersonationlevel=Impersonate,(Backup,Restore)}!root/wmi:BcdStore") >>> >>> if Err.number <> 0 then ... WScript.Quit(1) ... end if >>> >>> if not objBCD.OpenStore( "", objBcdStore ) then ... WScript.Quit(1) ... end if >>> >>> set objBCD = nothing >>> >>> if not objBcdStore.OpenObject( "{9dea862c-5cdd-4e70-acc1-f32b344d4795}", >>> objWBM ) then ... WScript.Quit(1) ... end if >>> >>> if not objWBM.SetIntegerElement( &h25000004, 10 ) then ... WScript.Quit(1) ... end if >>> >>> if not objWBM.GetElement( &h25000004, objElement ) then ... WScript.Quit(1) ... end if >>> >>> WScript.Echo objElement.Integer I execute both scripts from elevated command line. Can you please help? Thank you -- Radek Holý Czech republic _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32