congnt92 Posted May 14, 2014 Posted May 14, 2014 Hi to all.When I run this commandbcdedit /enum all /v > C:\List.txt. List.txt...Windows Memory Tester---------------------identifier {b2721d73-1db4-4c62-bf78-c548a880142d}device partition=C:path \boot\memtest.exedescription Windows Memory Diagnosticlocale en-USinherit {7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}badmemoryaccess YesReal-mode Boot Sector---------------------identifier {57b67fd0-dbb6-11e3-9719-9cb70d9fba21}description Grub4DOS...But there are so many information which I need. I just wan to get some lines belowReal-mode Boot Sector---------------------identifier {57b67fd0-dbb6-11e3-9719-9cb70d9fba21}description Grub4DOSI want creat batch file to do this. Is it impossible?Can anybody help me? Thanks
jaclaz Posted May 14, 2014 Posted May 14, 2014 Is it impossible?No. I want creat batch file to do this. Is it impossible?Can anybody help me?Yes.Learn about FOR /F with tokens and delims:http://www.robvanderwoude.com/ntfor.phphttp://www.robvanderwoude.com/ntfortokens.php You don't really need a temporary file.Namely:@ECHO OFFSETLOCAL ENABLEEXTENSIONSFOR /F "tokens=1,2 delims= " %%A IN ('bcdedit /enum all /v') DO (IF %%A.==identifier. SET %%A=%%BIF %%A.==description. SET %%A=%%BIF /I %%B.==grub4dos. GOTO :out):outSET identifierSET descriptionPAUSEIf you really want to create the text file, replace the FOR line with:bcdedit /enum all /v>C:\List.txtFOR /F "tokens=1,2 delims= " %%A IN (C:\List.txt) DO (jaclaz 1
congnt92 Posted May 14, 2014 Author Posted May 14, 2014 (edited) Work like a charm.Thanks so much, Jaclaz. God bless you Edited May 14, 2014 by congnt92
congnt92 Posted May 17, 2014 Author Posted May 17, 2014 (edited) Hi, JaclazI have a question. If menu boot contain Whitespace character, How can I edit your command to get some text which I want. i.e Menu boot is "Grub For Dos". I tried IF /I %%B.=="grub for dos". GOTO :outbut It's not working.Thanks Edited May 17, 2014 by congnt92
jaclaz Posted May 17, 2014 Posted May 17, 2014 Sure it is not. "%%B" in that case would be only "grub" as you have delims set to [sPACE] and tokens set to 1 and 2. Try with tokens=1,* <- the idea of giving you a reference is that you study the syntax, so that you can make changes yourself, but not "random" ones. Also you need quotes on both sides, like IF /I "%%B"=="grub for dos" GOTO :out jaclaz 1
congnt92 Posted May 18, 2014 Author Posted May 18, 2014 Thank you for your quick reply, JaclazNow I understand what differences between tokens=number and tokens=*.Have a nice day
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