Download - PA053879

BSEK (Backup/copy Software Evaluation Kit)の詳細情報 : Vector ソフトを探す!

-> [Go to the download page] -> [Download Now]

The Latest Snapshot - BSEK

@echo off
goto :begin

::-------------------------------------------------------------------------------------------------------------------------------------------------------------------
:: File Name: "bcde.bat" - Boot Configuration Data Edit BATch for Windows 7 (OEM_SLP) / PE3.x - BCD Builder/Generator
::
:: Copyright: Public Domain Software (NOT TO BE SHAREWARE OR FREEWARE)
::
:: Version (??: secondary series; can be revised by somebodies)
:: *.*?? by ***	May be revised for something
::
:: Version (ps: primary series; reserved for S. )
:: 1.?ps by S.	Revised to support removable external USB 2.0/3.0 Storage Devices (USB HDD/SSD/Memory etc.).
:: 1.0ps by S.	Created for bcdedit.exe
::
:: ToDo:
::
:: - Linux OSs should be supported.
::
:: Related Softwares (reference):
::
:: - Multiple Boot Manager: MBM R0.39 (freeware)
::   http://elm-chan.org/fsw/mbm/mbm_e.html
::   http://elm-chan.org/fsw/mbm/mbm.html
::   (elm-chan.org/fsw/mbm/mbm039.iso.gz)
:: - Plop Boot Manager 5.0.14 (USB 3.0 supported) (freeware)
::   http://www.plop.at/en/bootmanager/download.html
::
:: - MiniTool Partition Wizard Home Edition 7.8 Full version (freeware, 32bit)
::   http://www.partitionwizard.com/download.html
:: - Gnome Partition Editor: GParted live 0.19.0-1 (freeware, 32/64bit)
::   http://gparted.org/download.php
::
:: - Paragon Backup & Recovery, version 10.1.21.287 (16.12.13) Free (freeware, 32/64bit)
::   http://www.paragon-software.com/home/br-free/download.html
:: - Paragon Rescue Kit Free Edition (2011-04-28 15:03:47) (freeware, 32bit)
::   http://www.paragon-software.com/home/rk-express/download.html
::
:: - XBoot 1.0 Beta 14 (freeware, 32bit)
::   https://sites.google.com/site/shamurxboot/download
::
:: - Ridgecrop Consultants fat32format 1.07? (GUI version) (freeware, 32/64bit)
::   http://www.ridgecrop.demon.co.uk/index.htm?guiformat.htm
:: - 2Tware Fat32Format 1.13 (freeware, 32bit)
::   http://download.cnet.com/2Tware-Fat32Format/3000-2094_4-75623509.html
::
:: - bpb: displays information about a drive and the BPB on the volume (freeware, 32bit)
::   http://www.vector.co.jp/download/file/winnt/util/fh328130.html
::   http://ftp.vector.co.jp/pack/winnt/util/disk/status/bpb.zip
::
:: - PowerQuest Partition Table Editor (PTEDIT32.EXE) (freeware, 32bit)
::   ftp://ftp.symantec.com/public/english_us_canada/tools/pq/utilities/PTEDIT32.zip
:: - Acronis DiskEditor Demo version 6.0 (build 360) (freeware, 32bit)
::   (www.acronis.com/en-us/files/diskeditor6.0_d_en.exe)
::   Note: Check "Run as administrator" or "Run this program as an administrator" in Windows7 etc.
::
:: - FastCopy v2.11 (freeware, 32/64bit)
::   http://ipmsg.org/tools/fastcopy.html.en
::   http://www.vector.co.jp/download/file/win95/util/fh581932.html
::   http://www.vector.co.jp/download/file/win95/util/fh581931.html
::   http://ftp.vector.co.jp/pack/win95/util/file/FastCopy211.zip
::   http://ftp.vector.co.jp/pack/win95/util/file/FastCopy211_x64.zip
::
:: - 7-Zip Portable 9.20 Rev 3 (freeware, 32bit)
::   http://portableapps.com/apps/utilities/7-zip_portable
::
:: - Windows Automated Installation Kit (AIK): WAIK for Windows 7 (freeware, 32/64bit)
::   http://www.microsoft.com/en-us/download/details.aspx?id=5753
:: - Windows Automated Installation Kit (AIK): WAIK Supplement for Windows 7 SP1 (freeware, 32/64bit)
::   http://www.microsoft.com/en-us/download/details.aspx?id=5188
::
:: Related Links (reference):
::
:: - Goodells.Net :: Understanding MultiBooting
::   http://www.goodells.net/multiboot/ptable.shtml
:: - Using Disk Director to Change the Hidden Sectors field of an NTFS Logical Partition
::   http://www.themudcrab.com/acronis_hiddensectors.php
::
:: - Technical Details on Microsoft Product Activation for Windows XP
::   http://technet.microsoft.com/en-us/library/bb457054.aspx#EFAA
::
:: Notes
:: - Configuration Policy
::	Partition		Symbol	Description
::	-----------------------+-------+----------------------------------------------------------------------------------------------------------------------
::	Primary Partition 0	B0	"Windows 7 (32bit) @B0", "Windows Resume Application @B0", "Windows Boot Manager @BT", "Windows Memory Diagnostic @BT"
::	Primary Partition 1	B1	"Windows 7 (32bit) @B1", "Windows Resume Application @B1", "Windows Boot Manager @BT", "Windows Memory Diagnostic @BT"
::	Primary Partition 2	B2	"Windows 7 (64bit) @B2", "Windows Resume Application @B2", "Windows Boot Manager @BT", "Windows Memory Diagnostic @BT"
::	Logical Partition 0-1	L0-L1	Data Partition (NTFS/FAT32), and not Boot/System Partition (NTFS)
::	Logical Partition 2	L2	"Windows 7 (64bit) @L2", "Windows Resume Application @L2", "Windows Boot Manager @BT", "Windows Memory Diagnostic @BT"
::	Logical Partition 3	L3	"Windows 7 (32bit) @L3", "Windows Resume Application @L3", "Windows Boot Manager @BT", "Windows Memory Diagnostic @BT"
::	Logical Partition 4	L4	"Windows Recovery Environment @L4A", "Windows Setup @L4B", "Windows Boot Manager @BT", "Windows Memory Diagnostic @BT"
::	Logical Partition 5-7	L5-L7	reserved for alternative Data Partition (NTFS/FAT32) or Boot/System Partition (NTFS) on \Device\Harddisk0
::
::	- Recovery Partition (NTFS): B0->L4 (@B0A/@B0B->@L4A/@L4B)
::	- Default Boot/System Partition (NTFS): B1
::	- Boot/System Partition (NTFS): B0#->B0->B1/B2/L2/L3/L4 (@B0->@BT)
::	- Backup/Restore Availability: B0<=>L4, B1<=>L3, B2<=>L2, L0<=>L1
::
::	- "Windows Recovery Environment" and "Windows Setup" functions moved: B0->L4 (@B0A/@B0B->@L4A/@L4B)
::	  The Recovery Partition should be unhidden: 27h->07h with Partition Wizard etc.
::	  The Recovery Partition should be moved to a runt partition, e.g. the last partition of the disk #0. Then the 1st partition B0 will become free.
::
::	- "Windows Boot Manager" and "Windows Memory Diagnostic" functions moved: B0#->B0->B1/B2/L2/L3/L4 (@B0->@BT)
::	  The Boot Partition should be integrated to the Recovery Partition. i.e. "\bootmgr" and "\Boot\" should be copied to the Recovery Partition.
::	  The Boot Partition should be integrated to the other System Partitions. i.e. "\bootmgr" and "\Boot\" should be copied to the other System Partitions.
::	  And then the dedicated Boot Partition should be deleted.
::
:: - Help of bcdedit.exe ("::"=format, ":"=example, ":::"=template)
::		 bcdedit /createstore <filename>
:	call	:bcdedit /createstore "BCD_XX"
::		 bcdedit /export <filename>
:	call	:bcdedit /export "BCD-B0"
:	call	:bcdedit /export "BCD-B1"
:	call	:bcdedit /export "BCD-B2"
:	call	:bcdedit /export "BCD-L2"
:	call	:bcdedit /export "BCD-L3"
:	call	:bcdedit /export "BCD-L4"
::		 bcdedit /import <filename> [/clean]
:	call	:bcdedit /import "BCD_XX"
::		 bcdedit /sysstore <devicename>
::		 bcdedit [/store <filename>] /copy {<id>} /d <description>
::NG		 bcdedit /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
:::		 bcdedit /store "BCD_XX" /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
::		 bcdedit [/store <filename>] /delete <id> [/f] [/cleanup | /nocleanup]
::		 bcdedit [/store <filename>] /mirror {<id>}
::		 bcdedit [/store <filename>] /deletevalue [<id>] <datatype>
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
:::		 bcdedit /store "BCD_XX" /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
::		 bcdedit [/store <filename>] /enum [<type> | <id>] [/v]
:	call	:bcdedit /store "BCD_XX" /enum all /v > "BCD_XX.txt"
:	call	:bcdedit /store "C:\Boot\BCD" /enum all /v > "BCD-C.txt"
:	call	:bcdedit /store "D:\Boot\BCD" /enum all /v > "BCD-D.txt"
:	call	:bcdedit /store "E:\Boot\BCD" /enum all /v > "BCD-E.txt"
:	call	:bcdedit /store "F:\Boot\BCD" /enum all /v > "BCD-F.txt"
:	call	:bcdedit /store "G:\Boot\BCD" /enum all /v > "BCD-G.txt"
:	call	:bcdedit /store "H:\Boot\BCD" /enum all /v > "BCD-H.txt"
:	call	:bcdedit /store "I:\Boot\BCD" /enum all /v > "BCD-I.txt"
:	call	:bcdedit /store "J:\Boot\BCD" /enum all /v > "BCD-J.txt"
::		 bcdedit /v
::		 bcdedit /bootsequence <id> [...] [ /addfirst | /addlast | /remove ]
::		 bcdedit /default <id>
::		 bcdedit /displayorder <id> [...] [ /addfirst | /addlast | /remove ]
::		 bcdedit /timeout <timeout>
::		 bcdedit /toolsdisplayorder <id> [...] [ /addfirst | /addlast | /remove ]
::		 bcdedit /bootems [<id>] { ON | OFF }
::		 bcdedit /ems [<id>] { ON | OFF }
::		 bcdedit /emssettings [ BIOS ] | [ EMSPORT:<port> | [EMSBAUDRATE:<baudrate>] ]
::		 bcdedit /bootdebug [<id>] { ON | OFF }
::		 bcdedit /dbgsettings [ <debugtype> [DEBUGPORT:<port>] [BAUDRATE:<baud>] [CHANNEL:<channel>] [TARGETNAME:<targetname>] /start <startpolicy> /noumex ]
::		 bcdedit /debug [<id>] { ON | OFF }
::		 bcdedit /hypervisorsettings [ <debugtype> [DEBUGPORT:<port>] [BAUDRATE:<baud>] [CHANNEL:<channel>] ]
::-------------------------------------------------------------------------------------------------------------------------------------------------------------------

:begin
if .%1==.-h goto :usage
if .%1==.--help goto :usage
goto :exec

:usage
echo Preparations:
echo  A master boot manager for MBR ^(MBM etc.^) should be installed.
echo  The Recovery Partition should be unhidden: 27h-^>07h with Partition Wizard etc.
echo  The Boot Partition should be integrated to the other System Partitions.
echo  i.e. "\bootmgr" and "\Boot\" should be copied to the other System Partitions.
echo.
echo Usage:
echo  %~n0 [-h^|--help] [-l LOCALE] [-r PARTSYM] [-b PARTSYM] [-v] [-w] [-d] [BCDSUF]
echo  -h: display this help messages
echo  -l: change the locale of BCD file
echo  -r: change the Recovery Partition
echo  -b: change the Default Boot/System Partition
echo  -v: verbose mode for the output file of bcdedit
echo  -w: enable Windows ^(OEM_SLP^) on external drives
echo  -d: enable "detecthal" on external drives
echo  LOCALE: locale string such as en-US, ja-JP etc.
echo  PARTSYM: Partition Symbol ^(Primary: B0,B1.. Logical: L0,L1..^)
echo  BCDSUF: optional string as the suffix of BCD file
echo e.g.
echo  %~n0 -l en-US -r B0 -b B2 -v US
echo  %~n0 -l ja-JP -r B0 -b B2 JP
echo  %~n0 -l ja-JP -r L4 -b B1
goto :eof

:exec
rem "\hiberfil.sys" and "\pagefile.sys" should be disabled to extend storage capacity.
rem powercfg -HIBERNATE OFF

rem "AutoReboot" should be disabled to confirm Stop Error Code on BSoD (Blue Screen of Death).
rem reg add "HKLM\SYSTEM\CurrentControlSet\Control\CrashControl" /v "AutoReboot" /t REG_DWORD /d 0x0 /f
rem reg add "HKLM\SYSTEM\ControlSet001\Control\CrashControl" /v "AutoReboot" /t REG_DWORD /d 0x0 /f

rem Auto Defrag should be disabled to reduce the writing to drives.
rem reg add "HKLM\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction" /v "Enable" /t REG_SZ /d "N" /f
rem reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout" /v "EnableAutoLayout" /t REG_DWORD /d 0x0 /f

setlocal enabledelayedexpansion
rem if /I "%CD%"=="%SystemRoot%\System32" goto :abort
set _BCD_LN=eof
if not "%~1"=="" set _BCD_LN=%~1
if "%_BCD_LN:~,1%"==":" (
	shift /1
	goto %_BCD_LN%
)
if exist %~n0.log del %~n0.log

rem You may change the default locale of BCD file.
set _BCD_LB=en-US
set _BCD_LB=ja-JP
if .%1==.-l (
	set _BCD_LB=%~2
	shift /1
	shift /1
)

rem You may change the default Recovery Partition.
set _BCD_RP=B0
set _BCD_RP=L4
if .%1==.-r (
	set _BCD_RP=%~2
	shift /1
	shift /1
)

rem You may change the default of the Default Boot/System Partition.
set _BCD_BP=B2
set _BCD_BP=B1
if .%1==.-b (
	set _BCD_BP=%~2
	shift /1
	shift /1
)

if .%1==.-v (
	set _BCD_VM=1
	shift /1
)
if .%1==.-w (
	set _BCD_MD=%1
	shift /1
	if exist "%SystemRoot%\System32\slmgr.vbs" (
		set __STR=
		set __FLG=
		set __KEY=
		for /F "usebackq delims=" %%a in (
			`cscript %SystemRoot%\System32\slmgr.vbs -dli`
		) do (
rem			echo "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h"
			set __STR=%%a
			if not "!__STR!"=="" if /I not "!__STR!"=="!__STR:OEM_SLP=!" (
				echo !__STR!>con
				set __FLG=1
			)
		)
		if "!__FLG!"=="" (
			rem Technical Details on Microsoft Product Activation for Windows XP
			rem http://technet.microsoft.com/en-us/library/bb457054.aspx#EFAA
			echo.>con
			echo The current system is not for "OEM_SLP channel".>con
			echo So, product activation may be required for the systems on external drives.>con
			set /P __KEY=Are you sure you want to continue this operation [y,n]?>con
			if not "!__KEY!"=="y" goto :abort
		)
		set __STR=
		set __FLG=
		set __KEY=
	)
)
if .%1==.-d (
	set _BCD_DH=1
	shift /1
)
set _BCD_ER=0
set _BCD_DT=%DATE:/=-%_%TIME::=-%
set _BCD_DT=%_BCD_DT: =0%
set _BCD_DT=%_BCD_DT:~,-3%
echo -- Date_Time: %_BCD_DT%
if /I not "%CD%"=="%SystemRoot%\System32" (
	if /I not "!_BCD_LB!"=="en-US" if exist "!_BCD_LB!\diskpart.exe.mui" if not exist "%_BCD_DT%_diskpart.exe.mui" ren "!_BCD_LB!\diskpart.exe.mui" "%_BCD_DT%_diskpart.exe.mui"
	if not	exist "en-US" md "en-US"
	if not	exist "en-US\DISKPART.EXE.mui" if exist "%SystemRoot%\System32\en-US\diskpart.exe.mui" copy "%SystemRoot%\System32\en-US\diskpart.exe.mui" "en-US\DISKPART.EXE.mui" > nul
	if	exist "en-US\DISKPART.EXE.mui" if not exist "DISKPART.EXE" if exist "%SystemRoot%\System32\diskpart.exe" copy "%SystemRoot%\System32\diskpart.exe" "DISKPART.EXE" > nul
)
setlocal enabledelayedexpansion
set _BCD_CT=0123456789abcdefghijklmnopqrstuvwxyz
set _BCD_PR=
set _BCD_PL=
set _BCD_PC=0
set _BCD_LC=0
for /F "usebackq skip=8 tokens=2 delims= " %%p in (
	`"echo list disk|DISKPART"`
) do (
	for /F "usebackq skip=11 tokens=2-3 delims= " %%q in (
		`"(echo select disk %%p & echo list partition)|DISKPART"`
	) do (
		if not "!_BCD_PR!"=="" (
			set _BCD_PL=!_BCD_PL! !_BCD_PR!
			set _BCD_PR=
		)
		set _BCD_WP=
		set _BCD_TY=%%r
rem		if "!_BCD_TY!"=="プライマリ"	set _BCD_TY=Primary
rem		if "!_BCD_TY!"=="論理"		set _BCD_TY=Logical
		if "!_BCD_TY!"=="Primary" for %%s in (!_BCD_PC!) do (
			rem Set suffix numbers of Primary Partition, such as Data Partitions where you want to skip.
			if not %%s==100 if not %%s==101 (
				set _BCD_WP=B!_BCD_CT:~%%s,1!
				set _BCD_PR=%%p:%%q:!_BCD_WP!
			)
			set /A _BCD_PC+=1
		)
		if "!_BCD_TY!"=="Logical" for %%s in (!_BCD_LC!) do (
			rem Set suffix numbers of Logical Partition, such as Data Partitions where you want to skip.
			if not %%s==0 if not %%s==1 (
				set _BCD_WP=L!_BCD_CT:~%%s,1!
				set _BCD_PR=%%p:%%q:!_BCD_WP!
			)
			set /A _BCD_LC+=1
		)
		if not "!_BCD_PR!"=="" (
			rem Set a Default Boot "Primary" Harddisk:Partition No.
			if /I "!_BCD_WP!"=="!_BCD_BP!" (
				set _BCD_PR=!_BCD_PR!:+
			) else (
				set _BCD_PR=!_BCD_PR!:-
			)
			rem Set each OS Type : Version No.
			if %%p==0 (
				set _BCD_PR=!_BCD_PR!:W:7
			) else (
				if "!_BCD_MD!"=="-w" (
					set _BCD_PR=!_BCD_PR!:W:7
				) else (
					set _BCD_PR=!_BCD_PR!:P:3.1
				)
			)
			rem Set each Platform Type.
				if %%p:%%q==0:3 (
				set _BCD_PR=!_BCD_PR!:x64
			) else	if %%p:%%q==0:6 (
				set _BCD_PR=!_BCD_PR!:x64
			) else (
				set _BCD_PR=!_BCD_PR!:x86
			)
			rem Set each Notes.
			set _BCD_PR=!_BCD_PR!:
		)
rem		echo %%p %%q %%r	!_BCD_PC! !_BCD_LC!	"!_BCD_PR!"
		if /I "!_BCD_WP!"=="!_BCD_RP!" (
rem			echo.
rem			echo Unordered !_BCD_PC! !_BCD_LC! "!_BCD_PL!" "!_BCD_PR!"
			set _BCD_PR=!_BCD_PR!!_BCD_PL!
			set _BCD_PL=
rem			echo * Ordered !_BCD_PC! !_BCD_LC! "!_BCD_PL!" "!_BCD_PR!"
		)
	)
rem	echo.
rem	echo Unaligned !_BCD_PC! !_BCD_LC! "!_BCD_PL!" "!_BCD_PR!"
	set /A _BCD_PC="(!_BCD_PC! - 1 | 3) + 1"
	set /A _BCD_LC="(!_BCD_LC! - 1 | 3) + 1"
rem	echo * Aligned !_BCD_PC! !_BCD_LC! "!_BCD_PL!" "!_BCD_PR!"
)
endlocal & set _BCD_PL=%_BCD_PL:~1% %_BCD_PR%
if /I not "%CD%"=="%SystemRoot%\System32" (
	if /I not "!_BCD_LB!"=="en-US" if not exist "!_BCD_LB!\diskpart.exe.mui" if exist "!_BCD_LB!\%_BCD_DT%_diskpart.exe.mui" ren "!_BCD_LB!\%_BCD_DT%_diskpart.exe.mui" "diskpart.exe.mui"
	if	exist "en-US\DISKPART.EXE.mui" if exist "%SystemRoot%\System32\en-US\diskpart.exe.mui" del "en-US\DISKPART.EXE.mui"
	rd "en-US" > nul 2>&1
	if	exist "DISKPART.EXE" if exist "%SystemRoot%\System32\diskpart.exe" del "DISKPART.EXE"
)

rem You may overwrite the Partition List here, if you want to control manually.
rem Field 0 %%B HD: Harddisk No. (0..)
rem Field 1 %%C PN: Partition No. (1..)
rem Field 2 %%D PS: Partition Symbol (Primary: B0,B1.. Logical: L0,L1..)
rem Field 3 %%E DB: Default Boot flag (+|-)
rem Field 4 %%F OS: OS Type (W:Windows, P:WindowsPE on HDD; reserved L:Linux, C:CentOS, D:Debian, U:Ubuntu, F:Fedora etc.)
rem Field 5 %%G VR: Version No. (7, 8, 8.1; 3.0, 3.1, 4.0, 5.0 etc.)
rem Field 6 %%H PF: Platform Type (x86, x64 etc.)
rem Field 7 %%I NT: Notes - free short description
rem	echo.
rem	echo %_BCD_PL%
rem	set _BCD_PL=0:8:L4:-:W:7:x86: 0:1:B0:-:W:7:x86: 0:2:B1:+:W:7:x86: 0:3:B2:-:W:7:x64: 0:6:L2:-:W:7:x64: 0:7:L3:-:W:7:x86:
rem	set _BCD_PL=0:8:L4:-:W:7:x86: 0:1:B0:-:W:7:x86: 0:2:B1:+:W:7:x86: 0:3:B2:-:W:7:x64: 0:6:L2:-:W:7:x64: 0:7:L3:-:W:7:x86: 1:1:B4:-:P:3.1:x86: 1:2:B5:-:P:3.1:x86: 1:3:B6:-:P:3.1:x86: 1:4:L8:-:P:3.1:x86: 1:5:L9:-:P:3.1:x86: 1:6:La:-:P:3.1:x86: 1:7:Lb:-:P:3.1:x86: 1:8:Lc:-:P:3.1:x86: 1:9:Ld:-:P:3.1:x86: 1:10:Le:-:P:3.1:x86: 1:11:Lf:-:P:3.1:x86: 1:12:Lg:-:P:3.1:x86: 1:13:Lh:-:P:3.1:x86: 1:14:Li:-:P:3.1:x86: 1:15:Lj:-:P:3.1:x86:
rem	echo.
rem	echo %_BCD_PL%

set _BCD_PH=0
for %%A in (%_BCD_PL%) do for /F "tokens=1-8 delims=:" %%B in ("%%A") do (
	set _BCD_HD=%%B
	set _BCD_PN=%%C
	set _BCD_HP=\Device\Harddisk!_BCD_HD!\Partition!_BCD_PN!
	set _BCD_PS=%%D
	if .%%E==.+ (
		set _BCD_DB=+
	) else (
		set _BCD_DB=-
	)
		if .%%F==.P (
		set _BCD_OS=WindowsPE on HDD
rem	) else	if .%%F==.L (
rem		set _BCD_OS=Linux
rem	) else	if .%%F==.C (
rem		set _BCD_OS=CentOS Linux
rem	) else	if .%%F==.D (
rem		set _BCD_OS=Debian Linux
rem	) else	if .%%F==.U (
rem		set _BCD_OS=Ubuntu Linux
rem	) else	if .%%F==.F (
rem		set _BCD_OS=Fedora Linux
	) else (
		set _BCD_OS=Windows
	)
	set _BCD_VR=%%G
	set _BCD_PF=%%H
	set _BCD_NT=
	if not "%%I"=="" set _BCD_NT= %%I
	echo -- #!_BCD_PH! !_BCD_HP! Default:!_BCD_DB! !_BCD_OS! !_BCD_VR! !_BCD_PF!!_BCD_NT! @!_BCD_PS!

rem Indent Boundary -------------------------------------------------------------------------------------------------------------------------------------------------

if !_BCD_PH!==0 (
	set _BCD_RX=
	set _BCD_ST=BCD_XX
rem	set _BCD_ST=BCD_%_BCD_DT%
	if not "%~1"=="" set _BCD_ST=BCD_%~1
	if exist "!_BCD_ST!*" (
		attrib -s -h -r "!_BCD_ST!*"
		del "!_BCD_ST!*"
	)
::		 bcdedit /createstore <filename>
	call	:bcdedit /createstore "!_BCD_ST!"

rem dbgsettings
	set _BCD_ID={dbgsettings}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "デバッガー設定"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Debugger Settings"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! debugtype Serial
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! debugport 1
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! baudrate 115200

rem emssettings
	set _BCD_ID={emssettings}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "EMS 設定"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "EMS Settings"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootems Yes

rem badmemory
	set _BCD_ID={badmemory}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "RAM 不良"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "RAM Defects"

rem globalsettings
	set _BCD_ID={globalsettings}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "グローバル設定"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Global Settings"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {dbgsettings} {emssettings} {badmemory}

rem resumeloadersettings
	set _BCD_ID={resumeloadersettings}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem 	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "再開ローダー設定"
rem 	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Resume Loader Settings"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {globalsettings}

rem hypervisorsettings
	set _BCD_ID={hypervisorsettings}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "ハイパーバイザー設定"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Hypervisor Settings"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! hypervisordebugtype Serial
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! hypervisordebugport 1
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! hypervisorbaudrate 115200

rem bootloadersettings
	set _BCD_ID={bootloadersettings}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID!
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "ブート ローダー設定"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Boot Loader Settings"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {globalsettings} {hypervisorsettings}

rem memdiag
	set _BCD_ID={memdiag}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
rem ALT	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID! /d "Windows Memory Diagnostic @B0"
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID! /d "Windows Memory Diagnostic @BT"
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem ALT	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device boot
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\boot\memtest.exe"
rem ALT	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Memory Diagnostic @B0"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Memory Diagnostic @BT"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! locale !_BCD_LB!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {globalsettings}
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! badmemoryaccess Yes

rem bootmgr
	set _BCD_ID={bootmgr}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
rem ALT	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID! /d "Windows Boot Manager @B0"
	call	:bcdedit /store "!_BCD_ST!" /create !_BCD_ID! /d "Windows Boot Manager @BT"
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem ALT	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device boot
rem ALT	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Boot Manager @B0"
rem 	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Boot Manager @BT"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! locale !_BCD_LB!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {globalsettings}
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! default !_BCD_DF!
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! resumeobject !_BCD_RO!
rem Max. 6 entries for displayorder
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! displayorder !_BCD_DF! /addlast
rem Max. 3 entries for toolsdisplayorder
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! toolsdisplayorder {memdiag}!_BCD_RX!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! timeout 10
)

if "!_BCD_PS!"=="!_BCD_RP!" (
rem deviceoptionB0A
rem deviceoptionL4A
	set _BCD_ID={}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%p in (
		`call %~n0 :bcdedit /store "!_BCD_ST!" /create /device`
	) do (
		set _BCD_ID={%%p}
		set _BCD_DO={%%p}
	)
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "デバイス オプション @!_BCD_PS!A"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Device options @!_BCD_PS!A"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Ramdisk Options"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! ramdisksdidevice "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! ramdisksdipath "\Recovery\WindowsRE\boot.sdi"

rem recoverysequenceB0A
rem recoverysequenceL4A
	set _BCD_ID={}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%p in (
		`call %~n0 :bcdedit /store "!_BCD_ST!" /create /d "Windows Recovery Environment @!_BCD_PS!A" /application osloader`
	) do (
		set _BCD_ID={%%p}
		set _BCD_RS={%%p}
		set _BCD_RO={%%p}
		set _BCD_RX=!_BCD_RX! {%%p}
	)
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device "ramdisk=[!_BCD_HP!]\Recovery\WindowsRE\Winre.wim,!_BCD_DO!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\windows\system32\winload.exe"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Recovery Environment @!_BCD_PS!A"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! locale !_BCD_LB!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {bootloadersettings}
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! osdevice "ramdisk=[!_BCD_HP!]\Recovery\WindowsRE\Winre.wim,!_BCD_DO!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! systemroot "\windows"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! nx OptIn
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! winpe Yes

rem deviceoptionB0B
rem deviceoptionL4B
	set _BCD_ID={}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%p in (
		`call %~n0 :bcdedit /store "!_BCD_ST!" /create /device`
	) do (
		set _BCD_ID={%%p}
		set _BCD_DO={%%p}
	)
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "デバイス オプション @!_BCD_PS!B"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Device options @!_BCD_PS!B"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! ramdisksdidevice "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! ramdisksdipath "\boot\boot.sdi"

rem recoverysequenceB0B
rem recoverysequenceL4B
	set _BCD_ID={}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%p in (
		`call %~n0 :bcdedit /store "!_BCD_ST!" /create /d "Windows Setup @!_BCD_PS!B" /application osloader`
	) do (
		set _BCD_ID={%%p}
		set _BCD_RX=!_BCD_RX! {%%p}
	)
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device "ramdisk=[!_BCD_HP!]\sources\boot.wim,!_BCD_DO!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\windows\system32\winload.exe"
rem	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Setup @!_BCD_PS!B"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! locale !_BCD_LB!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {bootloadersettings}
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! osdevice "ramdisk=[!_BCD_HP!]\sources\boot.wim,!_BCD_DO!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! systemroot "\windows"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! detecthal Yes
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! winpe Yes
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! ems Yes

rem bootmgrB0A
rem bootmgrL4A
rem bootmgrB0B
rem bootmgrL4B
	set _BCD_ID={bootmgr}
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! resumeobject !_BCD_RO!
rem Max. 3 entries for toolsdisplayorder
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! toolsdisplayorder {memdiag}!_BCD_RX!
) else (
rem resumeXX
	set _BCD_ID={}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%p in (
		`call %~n0 :bcdedit /store "!_BCD_ST!" /create /d "Windows Resume Application @!_BCD_PS!" /application resume`
	) do (
		set _BCD_ID={%%p}
		set _BCD_RO={%%p}
	)
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\windows\system32\winresume.exe"
rem 	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "Windows Resume Application @!_BCD_PS!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! locale !_BCD_LB!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {resumeloadersettings}
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! filedevice "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! filepath "\hiberfil.sys"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! pae Yes
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! debugoptionenabled No

rem osloaderXX
	set _BCD_ID={}
::		 bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%p in (
		`call %~n0 :bcdedit /store "!_BCD_ST!" /create /d "!_BCD_OS! !_BCD_VR! !_BCD_PF!!_BCD_NT! @!_BCD_PS!" /application osloader`
	) do (
		set _BCD_ID={%%p}
		set _BCD_DF={%%p}
	)
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! device "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\windows\system32\winload.exe"
rem 	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! description "!_BCD_OS! !_BCD_VR! !_BCD_PF!!_BCD_NT! @!_BCD_PS!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! locale !_BCD_LB!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! inherit {bootloadersettings}
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! recoverysequence !_BCD_RS!
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! recoveryenabled Yes
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! osdevice "partition=!_BCD_HP!"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! systemroot "\windows"
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! resumeobject !_BCD_RO!
rem BCDEdit /set (Windows Drivers)
rem http://msdn.microsoft.com/en-us/library/windows/hardware/ff542202(v=vs.85).aspx
::		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! nx [ OptIn | OptOut | AlwaysOn | AlwaysOff ]
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! nx OptIn
rem		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! quietboot [ on | off ]
rem		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootux [ disabled | basic | standard ]
rem		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootmenupolicy [ Legacy | Standard ]
rem		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! onetimeadvancedoptions [ on | off ]
rem		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! pae [ Default | ForceEnable | ForceDisable ]
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! pae Default
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! pae ForceEnable
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! pae ForceDisable
rem		 bcdedit /store "!_BCD_ST!" /set !_BCD_ID! pciexpress [ default | forcedisable]
rem
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! recoveryenabled No
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootstatuspolicy IgnoreAllFailures
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootstatuspolicy IgnoreBootFailures
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootstatuspolicy IgnoreShutdownFailures
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootstatuspolicy DisplayAllFailures
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! testsigning Yes
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! sos Yes
REM	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! bootlog Yes
	if not .%%F==.P if not "!_BCD_DH!"=="" if !_BCD_HD! GEQ 1 (
		call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! detecthal Yes
	)
rem Walkthrough: Boot Windows PE from a BIOS-based Hard Disk
rem http://technet.microsoft.com/en-us/library/dd799294(v=ws.10).aspx
rem Walkthrough: Boot Windows PE from Hard Disk
rem http://technet.microsoft.com/en-us/library/cc722114(v=ws.10).aspx
	if .%%F==.P (
rem 		call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\windows\system32\winload.exe"
		call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! path "\windows\system32\boot\winload.exe"
		call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! detecthal Yes
		call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! winpe Yes
	)

rem bootmgrXX
	set _BCD_ID={bootmgr}
::		 bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
rem Max. 6 entries for displayorder
	call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! displayorder !_BCD_DF! /addlast
	if "!_BCD_DB!"=="+" (
		call	:bcdedit /store "!_BCD_ST!" /set !_BCD_ID! default !_BCD_DF!
	)
)

rem Indent Boundary -------------------------------------------------------------------------------------------------------------------------------------------------

	set /A _BCD_PH+=1
)

rem enum
if exist "%_BCD_ST%" (
	copy /Y "%_BCD_ST%" "BCD-ENUM" > nul
::		 bcdedit [/store <filename>] /enum [<type> | <id>] [/v]
	if not "!_BCD_VM!"=="" (
		call	:bcdedit /store "BCD-ENUM" /enum all /v	> "%_BCD_ST%.txt"
	) else (
		call	:bcdedit /store "BCD-ENUM" /enum all	> "%_BCD_ST%.txt"
	)
	if exist "BCD-ENUM*" (
		attrib -s -h -r "BCD-ENUM*"
		del "BCD-ENUM*"
	)
)

rem batch file to re-label
if exist "bcdlabel.bat" del "bcdlabel.bat"
if exist "%_BCD_ST%.txt" (
	echo @echo off>bcdlabel.bat
	echo setlocal enabledelayedexpansion>>bcdlabel.bat
	echo set __KEY=>>bcdlabel.bat
	echo set /P __KEY=Do you want to re-label each partition [y,n]?>>bcdlabel.bat
	echo if not "^!__KEY^!"=="y" goto :abort>>bcdlabel.bat
	echo.>>bcdlabel.bat
	echo :: Label Structure>>bcdlabel.bat
	echo :: Field a PS: Partition Symbol ^(Primary: B0,B1.. Logical: L0,L1..^)>>bcdlabel.bat
	echo :: Field b OS: OS Type ^(W:Windows, P:WindowsPE on HDD^)>>bcdlabel.bat
	echo :: Field c VR: Version No. ^(Major No. * 10 + Minor No.^)>>bcdlabel.bat
	echo :: Field d PF: Platform Type ^(e5 = 2^^5: 32bit: x86, e6 = 2^^6: 64bit: x64^)>>bcdlabel.bat
	echo ::      a b c d>>bcdlabel.bat
	echo ::      --=---==>>bcdlabel.bat
	for /F "usebackq tokens=1* delims=	 " %%a in ("%_BCD_ST%.txt") do (
rem		echo "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h"
		if /I "%%~a"=="device" (
			set _BCD_LP=
			for /F "usebackq tokens=1-2* delims==[]" %%a in ('%%~b') do (
rem				echo "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h"
				if /I "%%~a"=="partition" (
					set _BCD_LP=%%~b
				) else if /I "%%~a"=="ramdisk" (
					set _BCD_LP=%%~b
				) else if /I "%%~a"=="vhd" (
					set _BCD_LP=%%~b
				)
				if not "!_BCD_LP!"=="" if not "!_BCD_LP:~1!"==":" set _BCD_LP=
			)
		) else if /I "%%~a"=="description" (
			if not "!_BCD_LP!"=="" (
				for /F "usebackq tokens=1* delims=@" %%a in ('%%~b') do (
rem					echo "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h"
					set _BCD_LP=!_BCD_LP!%%~b
					if not "!_BCD_LP!"=="" set _BCD_LP=!_BCD_LP:~,4!%%~a
					if not "!_BCD_LP!"=="" if "!_BCD_LP:Resume=!"=="!_BCD_LP!" if "!_BCD_LP:Setup=!"=="!_BCD_LP!" (
						if not "!_BCD_LP!"=="" set _BCD_LP=!_BCD_LP:Windows Recovery Environment=Windows 7 x86!
						if not "!_BCD_LP!"=="" set _BCD_LP=!_BCD_LP:WindowsPE on HDD=P!
						if not "!_BCD_LP!"=="" set _BCD_LP=!_BCD_LP:Windows=W!
						rem x86: 32bit: 2^5 = e5
						rem x64: 64bit: 2^6 = e6
						if not "!_BCD_LP!"=="" set _BCD_LP=!_BCD_LP:x86=e5!
						if not "!_BCD_LP!"=="" set _BCD_LP=!_BCD_LP:x64=e6!
						for /F "usebackq tokens=1-4* delims=.	 " %%a in ('!_BCD_LP!') do (
rem							echo "%%~a" "%%~b" "%%~c" "%%~d" "%%~e" "%%~f" "%%~g" "%%~h"
							set _BCD_VH=0%%~b
							if not "!_BCD_VH!"=="" set _BCD_VH=!_BCD_VH:~-2!
							if not "!_BCD_LP!"=="" (
								if not "!_BCD_LP:.=!"=="!_BCD_LP!" (
									set _BCD_VL=%%~c
									if not "!_BCD_VL!"=="" set _BCD_VL=!_BCD_VL:~,1!
									set _BCD_LP=%%~a!_BCD_VH!!_BCD_VL!%%~d
								) else (
									set _BCD_LP=%%~a!_BCD_VH!0%%~c
								)
							)
						)
						echo label !_BCD_LP!>>bcdlabel.bat
					)
				)
			)
		)
	)
	echo.>>bcdlabel.bat
	echo :abort>>bcdlabel.bat
	echo endlocal>>bcdlabel.bat
)

rem info
if not %_BCD_ER%==0 goto :abort
if exist "%_BCD_ST%" (
	if exist "%_BCD_ST%.LOG?" (
		attrib -s -h -r "%_BCD_ST%.LOG?"
		del "%_BCD_ST%.LOG?"
	)
	echo.
	if exist "%~n0.log" echo Check "%~n0.log" for %~n0.
	if exist "%_BCD_ST%.txt" echo Check "%_BCD_ST%.txt" for BCD.
	if exist "bcdlabel.bat" echo Type "bcdlabel.bat" to check it. You may use it to re-label.
	echo Boot Configuration Data "%_BCD_ST%" has been generated.
	echo Copy "%_BCD_ST%" "\Boot\BCD" ^&: to apply the generated BCD.
	echo Done: %~n0
)
goto :exit

:bcdedit
if "%_BCD_LN%"==":bcdedit" (
	(echo rem %_BCD_LN%)		>>%~n0.log
	set _BCD_CL=%*
	if "!_BCD_CL:~,1!"==":" set _BCD_CL=!_BCD_CL:~1!
	(echo		!_BCD_CL!)	>>%~n0.log
			!_BCD_CL!
	rem ERRORS CANNOT BE COUNTED
	if errorlevel 1 (echo rem	UNCOUNTED ERROR&echo.)	>>%~n0.log
) else (
	rem "%*" cannot be operated by "shift /1"
	(echo		bcdedit %*)	>>%~n0.log
			bcdedit %*
)
if errorlevel 1 (
	set /A _BCD_ER+=1
	echo Error: !_BCD_ER! counted
	%~n0 :abort
	exit /B 1
)
exit /B 0

:abort
if not "%_BCD_ST%"=="" if exist "%_BCD_ST%*" (
	attrib -s -h -r "%_BCD_ST%*"
	del "%_BCD_ST%*"
)
echo.
echo Aborted: %~n0
endlocal
rem pause
exit /B 1

:exit
endlocal
rem pause
exit /B 0

:eof
/* Copyright: Public Domain (free contents) for the contents in the just above element. */
/* Everyone can copy, revise and distribute/publish the contents in the just above element. */
/* Everyone can copy, paste, save and use the contents in the just above element. */

Links - PA053879

Top Page - PA053879

BSEK (Backup/copy Software Evaluation Kit)

Windows システムをファイルコピー型バックアップする検討内容

"xcpt.bat" - eXtended CoPy Test BATch for Windows7 HP 64bit(x64)

"xcp.bat" - eXtended CoPy BATch for Windows7 HP 64bit(x64)

"xat.bat" - eXtended ATtrib BATch for Windows7 HP 64bit(x64)

"bcde.bat" - Boot Configuration Data Edit BATch for Windows 7 (OEM_SLP) / PE3.x - BCD Builder/Generator

"t2hp.bat" - Text TO xHtml Parts BATch for perl

"dddi.bat" - Device class Drivers DisInstaller / Inactive-Installer BATch for Windows 7 (OEM_SLP) / PE3.x

"bpbf.bat" - "BPB" display tool text Filtering wrapper

The making of the integrated ISO file / bootable CD/DVD/BD

The making of 2048[sct] aligned / 2^n[GB] normalized partitions

Ideal 2TB HDD, 256GB partitions, Optimal alignment

Ideal 2TB HDD, 256GB partitions, with gaps for Cyl. boundary

Ideal 2TB HDD, 128GB partitions, Optimal alignment

Ideal 2TB HDD, 128GB partitions, with gaps for Cyl. boundary

Ideal 2TB HDD, 64GB partitions, Optimal alignment

Ideal 2TB HDD, 64GB partitions, with gaps for Cyl. boundary

I-O DATA HDPC-UT, 64GB partitions, with gaps for Cyl. boundary

Hitachi HTS545050B9A300, 64GB partitions, with gaps for Cyl. boundary

FUJITSU MHT2030AT, 8GB partitions, with gaps for Cyl. boundary

Ideal USB Memory, single partition, Optimal alignment

The making of USB bootable system for Windows 7 (OEM_SLP) / PE3.x

counter