Sign in to follow this  
Followers 0
step887

WMI BCDstore

4 posts in this topic

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. 

Share this post


Link to post
Share on other sites



Anyone?

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by AutoBert

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by step887

Share this post


Link to post
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
Sign in to follow this  
Followers 0