Jump to content

WMI BCDstore


Recommended Posts

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

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 by step887
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...