vacko Posted February 12, 2012 Share Posted February 12, 2012 Hello, could you help to check what is wrong with my BCDedit function ? When I run it, no any new entry is added into BCD. Even MsgBox doesn't return any GUID (actually I return 0, but this is error code of RUN function, right ?). So, I think function doesn't work. #include <Constants.au3> #include <String.au3> BCDaddVHD("c:\boot\BCD", "TEST") Func BCDaddVHD($BCDstore, $BCDmodel) $guidreturn = Run(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/create /d ' & $BCDmodel & ' /application OSLOADER', "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWait ($guidreturn,5) Do $line = StdoutRead($guidreturn) & StderrRead($guidreturn) Until $line = not "" $guid = _StringBetween($line, '{', '}') RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} device vhd=[locate]\vhd\' & $BCDmodel & '.vhd', "", @SW_HIDE) RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} osdevice vhd=[locate]\vhd\' & $BCDmodel & '.vhd', "", @SW_HIDE) RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} path \Windows\system32\winload.exe', "", @SW_HIDE) RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} systemroot \Windows', "", @SW_HIDE) RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} detecthal Yes', "", @SW_HIDE) RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} locale en-US', "", @SW_HIDE) RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/displayorder {' & $guid & '} /addlast', "", @SW_HIDE) MsgBox(0,"Info", "Entry "&$BCDmodel&" with GUID " &$guid& " created") EndFunc I think some quotes are bad or missing, but because I'm just beginner with AutoIt, I don't know what rule I need follow and how to fix it. Link to comment Share on other sites More sharing options...
wakillon Posted February 12, 2012 Share Posted February 12, 2012 Try to add a space after each $BCDstore & ' AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
water Posted February 12, 2012 Share Posted February 12, 2012 (edited) Just a few quick ideas to test: Insert a space after each $BCDstore e.g.$BCDstore & '/set ...to$BCDstore & ' /set ...That's not only true for "/set" but for "/displayorder" too. If BCDstore returns an exit code you can check tof this code: $iResult = RunWait(@ComSpec & ' /c bcdedit /store ' & $BCDstore & '/set {' & $guid & '} device vhd=[locate]vhd' & $BCDmodel & '.vhd', "", @SW_HIDE) If $iResult <> 0 Then ... Edited February 12, 2012 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vacko Posted February 12, 2012 Author Share Posted February 12, 2012 Thanks, we have some progress, I inserted spaces as advised, also changed ' & $BCDmodel & ' to "' & $BCDmodel & '" because entry name have to be in double quotes (it's required by BCDedit, I forgot this...). So BCDedit /create now works (even physically add entry into BCD file), but all other BCDedit commands doesn't work, because $guid return nothing (but not zero). Any advise ? Link to comment Share on other sites More sharing options...
JFX Posted February 12, 2012 Share Posted February 12, 2012 (edited) your main problem is the ProcessWait ($guidreturn,5) remove it.also reread: http://www.autoitscript.com/autoit3/docs/functions/StdoutRead.htmPS: There also no need for @ComSpec /c here Edited February 12, 2012 by JFX Link to comment Share on other sites More sharing options...
wakillon Posted February 12, 2012 Share Posted February 12, 2012 And _StringBetween return a 0 based $array[0] contains the first found string ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
vacko Posted February 12, 2012 Author Share Posted February 12, 2012 And _StringBetween return a 0 based $array[0] contains the first found string ! You are right, I tried remove ProcessWait ($guidreturn,5) and @ComSpec /c but no any significant effect. $line returns: The entry {7ac016c3-5599-11e1-8da7-00261882441b} was sucessfully created. But _StringBetween can't handle it and return nothing, so $guid is also empty. Could you help to explain me on below example (or in my original code) how to solve it ? #include <String.au3> $line = "The entry {7ac016c3-5599-11e1-8da7-00261882441b} was sucessfully created." $guid = _StringBetween($line, '{', '}') MsgBox(1, "Info", "GUID is" & $guid) Link to comment Share on other sites More sharing options...
vacko Posted February 12, 2012 Author Share Posted February 12, 2012 @wakillon: never mind, just found how to fix it... Thanks to everybody, now it's functional. BTW, is there any other way how to add entry into BCD ? When compare my script (or my previously used .bat file) with EasyBCD, adding new entry take much more time. Especially when I will need add 20 or more entries one-by-one. Link to comment Share on other sites More sharing options...
JFX Posted February 12, 2012 Share Posted February 12, 2012 When compare my script (or my previously used .bat file) with EasyBCD, adding new entry take much more time.Especially when I will need add 20 or more entries one-by-one.EasyBCD is just a wrapper for bcdedit.exe just like your Autoit3 script.If should not be faster, properly you used it on your system bcd store that is persistent inside the registry all the time Using bcdedit.exe -store ... will load, unload and save the bcd hive to disk every time you call it, what takes a bit time. 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