@echo off
	goto begin

::------------------------------------------------------------------------------------------------------------------------------------------------------------
:: File Name: "bcde.bat" - Boot Configuration Data Edit BATch for Windows7 HP
::
:: 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.0ps by S.	Created for bcdedit.exe
::
:: Related Softwares (reference):
:: - Partition Wizard Home Edition 5.2 Full version (freeware, 32/64bit)
::   http://www.partitionwizard.com/download.html
:: - Multiple Boot Manager: MBM R0.39 (freeware)
::   http://elm-chan.org/fsw/mbm/mbm.html
::
:: Notes
:: - Configuration
::	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-8	L5-L8	Alternative Data Partition (NTFS/FAT32), and not Boot/System Partition (NTFS)
::
::	- Boot/System Partition (NTFS): B0/B1/B2/L2/L3/L4
::	- Default Boot/System Partition (NTFS): B1
::	- "Windows Boot Manager" and "Windows Memory Diagnostic" functions copied: B0->B1/B2/L2/L3/L4 (@B0->@BT)
::	- "Windows Recovery Environment" and "Windows Setup" functions temporarily replaced: B0->L4 (@B0a/@B0b->@L4a/@L4b)
::	- Backup/Restore Availability: B1<=>L3, B2<=>L2, L0<=>L1, L5<=>L6, L7<=>L8
::
:: - Help of bcdedit.exe ("::"=format, ":"=example, ":::"=template)
::	bcdedit /createstore <filename>
:	bcdedit /createstore BCD_XX
::	bcdedit /export <filename>
:	bcdedit /export BCD-B0
:	bcdedit /export BCD-B1
:	bcdedit /export BCD-B2
:	bcdedit /export BCD-L2
:	bcdedit /export BCD-L3
:	bcdedit /export BCD-L4
::	bcdedit /import <filename> [/clean]
:	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]
:	bcdedit /store BCD_XX /enum all /v > BCD_XX.txt
:	bcdedit /store C:\Boot\BCD /enum all /v > BCD-C.txt
:	bcdedit /store D:\Boot\BCD /enum all /v > BCD-D.txt
:	bcdedit /store E:\Boot\BCD /enum all /v > BCD-E.txt
:	bcdedit /store F:\Boot\BCD /enum all /v > BCD-F.txt
:	bcdedit /store G:\Boot\BCD /enum all /v > BCD-G.txt
:	bcdedit /store H:\Boot\BCD /enum all /v > BCD-H.txt
:	bcdedit /store I:\Boot\BCD /enum all /v > BCD-I.txt
:	bcdedit /store J:\Boot\BCD /enum all /v > BCD-J.txt
:	bcdedit /store K:\Boot\BCD /enum all /v > BCD-K.txt
:	bcdedit /store L:\Boot\BCD /enum all /v > BCD-L.txt
:	bcdedit /store M:\Boot\BCD /enum all /v > BCD-M.txt
:	bcdedit /store N:\Boot\BCD /enum all /v > BCD-N.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 Usage: %~n0 [-h^|--help] [BCD_SUFFIX]
	goto exit

:exec
:: hiberfil.sys and pagefile.sys are to be disabled to extend storage capacity
:	powercfg -HIBERNATE OFF

	set _BCD_B0=\Device\HarddiskVolume1
	set _BCD_B1=\Device\HarddiskVolume2
	set _BCD_B2=\Device\HarddiskVolume3
:	set _BCD_L0=\Device\HarddiskVolume4
:	set _BCD_L1=\Device\HarddiskVolume5
	set _BCD_L2=\Device\HarddiskVolume6
	set _BCD_L3=\Device\HarddiskVolume7
	set _BCD_L4=\Device\HarddiskVolume8
:	set _BCD_L5=\Device\HarddiskVolume9
:	set _BCD_L6=\Device\HarddiskVolume10
:	set _BCD_L7=\Device\HarddiskVolume11
:	set _BCD_L8=\Device\HarddiskVolume12
	set _BCD_ST=BCD_XX
	if not "%~1"=="" set _BCD_ST=BCD_%~1
	set _BCD_RX=

	if exist "%_BCD_ST%" del "%_BCD_ST%"
::	bcdedit /createstore <filename>
	bcdedit /createstore "%_BCD_ST%"

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

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

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

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

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

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

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

:deviceoptionB0a
:deviceoptionL4a
::	bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /create /device`
	) do (
		set _BCD_ID={%%i}
		set _BCD_DO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "デバイス オプション @B0a"
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "デバイス オプション @L4a"
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Ramdisk Options"
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ramdisksdidevice partition=%_BCD_B0%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ramdisksdidevice partition=%_BCD_L4%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ramdisksdipath \Recovery\WindowsRE\boot.sdi

:recoverysequenceB0a
:recoverysequenceL4a
::	bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /create /d "Windows Recovery Environment @L4a" /application osloader`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RS={%%i}
		set _BCD_RX=%_BCD_RX% {%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device ramdisk=[%_BCD_B0%]\Recovery\WindowsRE\Winre.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device ramdisk=[%_BCD_L4%]\Recovery\WindowsRE\Winre.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% path \windows\system32\winload.exe
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Recovery Environment @B0a"
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Recovery Environment @L4a"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% locale ja-JP
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% inherit {bootloadersettings}
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice ramdisk=[%_BCD_B0%]\Recovery\WindowsRE\Winre.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice ramdisk=[%_BCD_L4%]\Recovery\WindowsRE\Winre.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% systemroot \windows
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% nx OptIn
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% winpe Yes

:deviceoptionB0b
:deviceoptionL4b
::	bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /create /device`
	) do (
		set _BCD_ID={%%i}
		set _BCD_DO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "デバイス オプション @B0b"
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "デバイス オプション @L4b"
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ramdisksdidevice partition=%_BCD_B0%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ramdisksdidevice partition=%_BCD_L4%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ramdisksdipath \boot\boot.sdi

:recoverysequenceB0b
:recoverysequenceL4b
::	bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /create /d "Windows Setup @L4b" /application osloader`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RX=%_BCD_RX% {%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device ramdisk=[%_BCD_B0%]\sources\boot.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device ramdisk=[%_BCD_L4%]\sources\boot.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% path \windows\system32\winload.exe
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Setup @B0b"
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Setup @L4b"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% locale ja-JP
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% inherit {bootloadersettings}
:ALT	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice ramdisk=[%_BCD_B0%]\sources\boot.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice ramdisk=[%_BCD_L4%]\sources\boot.wim,%_BCD_DO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% systemroot \windows
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% detecthal Yes
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% winpe Yes
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% ems Yes

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

:resumeB0
::	bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /create /d "Windows Resume Application @B0" /application resume`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_B0%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% path \windows\system32\winresume.exe
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Resume Application @B0"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% locale ja-JP
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% inherit {resumeloadersettings}
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% filedevice partition=%_BCD_B0%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% filepath \hiberfil.sys
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% pae Yes
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% debugoptionenabled No

:osloaderB0
::	bcdedit [/store <filename>] /create [{<id>}] [/d <description>] [/application <apptype> | /inherit [<apptype>] | /inherit DEVICE | /device]
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /create /d "Windows 7 (32bit) @B0" /application osloader`
	) do (
		set _BCD_ID={%%i}
		set _BCD_DF={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_B0%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% path \windows\system32\winload.exe
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows 7 (32bit) @B0"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% locale ja-JP
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% inherit {bootloadersettings}
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% recoverysequence %_BCD_RS%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% recoveryenabled Yes
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice partition=%_BCD_B0%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% systemroot \windows
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% resumeobject %_BCD_RO%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% nx OptIn

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

:resumeB1
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_RO% /d "Windows Resume Application @B1"`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_B1%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Resume Application @B1"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% filedevice partition=%_BCD_B1%

:osloaderB1
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_DF% /d "Windows 7 (32bit) @B1"`
	) do (
		set _BCD_ID={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_B1%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows 7 (32bit) @B1"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice partition=%_BCD_B1%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% resumeobject %_BCD_RO%

:bootmgrB1
	set _BCD_DF=%_BCD_ID%
	set _BCD_ID={bootmgr}
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% default %_BCD_DF%

:resumeB2
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_RO% /d "Windows Resume Application @B2"`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_B2%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Resume Application @B2"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% filedevice partition=%_BCD_B2%

:osloaderB2
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_DF% /d "Windows 7 (64bit) @B2"`
	) do (
		set _BCD_ID={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_B2%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows 7 (64bit) @B2"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice partition=%_BCD_B2%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% resumeobject %_BCD_RO%

:resumeL2
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_RO% /d "Windows Resume Application @L2"`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_L2%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Resume Application @L2"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% filedevice partition=%_BCD_L2%

:osloaderL2
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_DF% /d "Windows 7 (64bit) @L2"`
	) do (
		set _BCD_ID={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_L2%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows 7 (64bit) @L2"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice partition=%_BCD_L2%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% resumeobject %_BCD_RO%

:resumeL3
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_RO% /d "Windows Resume Application @L3"`
	) do (
		set _BCD_ID={%%i}
		set _BCD_RO={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_L3%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows Resume Application @L3"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% filedevice partition=%_BCD_L3%

:osloaderL3
::	bcdedit [/store <filename>] /copy {<id>} /d <description>
	for /F "usebackq tokens=2 delims={}" %%i in (
		`bcdedit /store "%_BCD_ST%" /copy %_BCD_DF% /d "Windows 7 (32bit) @L3"`
	) do (
		set _BCD_ID={%%i}
	)
::	bcdedit [/store <filename>] /set [{<id>}] <datatype> <value> [ /addfirst | /addlast | /remove ]
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% device partition=%_BCD_L3%
:	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% description "Windows 7 (32bit) @L3"
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% osdevice partition=%_BCD_L3%
	bcdedit /store "%_BCD_ST%" /set %_BCD_ID% resumeobject %_BCD_RO%

:enum
::	bcdedit [/store <filename>] /enum [<type> | <id>] [/v]
	if .%1==.-v (
		bcdedit /store "%_BCD_ST%" /enum all /v > "%_BCD_ST%.txt"
	) else (
		bcdedit /store "%_BCD_ST%" /enum all    > "%_BCD_ST%.txt"
	)
	echo.
	if exist "%_BCD_ST%.txt" echo Check "%_BCD_ST%.txt".
	if exist "%_BCD_ST%" echo Boot Configuration Data "%_BCD_ST%" was generated.
	if exist "%_BCD_ST%" echo Copy "%_BCD_ST%" to "\Boot\BCD", and then it will be applied.
	echo Done: %~n0
	goto exit

:abort
	echo.
	echo Aborted: %~n0
:exit
	set _BCD_B0=
	set _BCD_B1=
	set _BCD_B2=
:	set _BCD_L0=
:	set _BCD_L1=
	set _BCD_L2=
	set _BCD_L3=
	set _BCD_L4=
:	set _BCD_L5=
:	set _BCD_L6=
:	set _BCD_L7=
:	set _BCD_L8=
	set _BCD_ST=
	set _BCD_RX=
	set _BCD_ID=
	set _BCD_DO=
	set _BCD_RS=
	set _BCD_RO=
	set _BCD_DF=
	pause
:end
/* Copyright: Public Domain (free contents) for the inside of this border. */
/* Everyone can copy, revise and distribute/publish the contents in the inside of this border. */