step887 Posted March 30, 2016 Share Posted March 30, 2016 I am trying to open the operating system currently in use, using WMI . Found this Autoit BCD and technet blog Trying to do this Const BcdLibraryString_Description = &h12000004 Const Current = "{fa926493-6f1c-4193-a414-58f0b2456d1e}" strComputer = "." Set objStoreClass = GetObject("winmgmts:{(Backup,Restore)}\\" & _ strComputer & "\root\wmi:BcdStore") objStoreClass.OpenStore "", objStore objStore.OpenObject Current, objDefault objDefault.GetElement BcdLibraryString_Description, objElement Wscript.Echo "Current operating system: " & objElement.String Here is what I have, but the $obCurrent is not an object. #RequireAdmin Const $BCDWindowsImageType = 0x10200003 Const $BCDLegacyImageType = 0x10300006 Const $BCDLibString_Desc = 0x12000004 Const $BcdOSLoaderDevice_OSDevice = 0x21000001 $Current = "{fa926493-6f1c-4193-a414-58f0b2456d1e}" Local $WMILocator = ObjCreate("WbemScripting.SWbemLocator") $WMILocator.Security_.Privileges.AddAsString('SeBackupPrivilege') $WMILocator.Security_.Privileges.AddAsString('SeRestorePrivilege') Local $WMIRootNameSpace = $WMILocator.ConnectServer(@ComputerName, "root\wmi") Local $oStoreClass = $WMIRootNameSpace.Get("BcdStore") Local $objInParam = $oStoreClass.Methods_('OpenStore').InParameters.SpawnInstance_() $objInParam.Properties_.Item('File') = "" Local $oBCDStore = $oStoreClass.ExecMethod_('OpenStore',$objInParam).Store ; The Store property contains our object value If IsObj($oBCDStore) Then $obCurrent =$oBCDStore.OpenObject($Current) MsgBox(0,0,IsObj($obCurrent)) EndIf I am not the best at Objects, so any help will be appreciated. Link to comment Share on other sites More sharing options...
step887 Posted March 31, 2016 Author Share Posted March 31, 2016 Anyone? Link to comment Share on other sites More sharing options...
AutoBert Posted March 31, 2016 Share Posted March 31, 2016 (edited) Try: $Current = ObjGet("{fa926493-6f1c-4193-a414-58f0b2456d1e}") in your script $current is a stringvariable no object, so $ObjCurrent is also a stringvar. Edited March 31, 2016 by AutoBert Link to comment Share on other sites More sharing options...
step887 Posted March 31, 2016 Author Share Posted March 31, 2016 (edited) thanks for your reply. However,that did not work test.au3 (7) : ==> COM Error intercepted ! err.number is: 0x800401E4 err.windescription: Invalid syntax err.description is: err.source is: err.helpfile is: err.helpcontext is: 10606000 err.lastdllerror is: 2 err.scriptline is: 7 err.retcode is: 0x00A1D950 Edited March 31, 2016 by step887 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now