echo.
echo Running command to active high-performance power scheme
echo powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
echo.
echo Check %WinPESource%images
if exist %WinPESource%imagesinstall.wim echo Find %WinPESource%imagesinstall.wim && set IMAGETYPE=WIM
if exist %WinPESource%imagesinstall.swm echo Find %WinPESource%imagesinstall.swm && set IMAGETYPE=SWM
if not defined IMAGETYPE echo Image not find in %WinPESource%images && goto :ERROR
REM eMMC disk is the first choice to install Windows
echo.
echo Try to find a fixed internal disk
echo.
for /l %%i in (3,-1,0) do (
echo select disk %%i > x:detdisk.txt
echo detail disk >> x:detdisk.txt
diskpart /s x:detdisk.txt > x:det.txt
find /i "Type : SD" x:det.txt
if not errorlevel 1 set Disk=%%i
)
if defined Disk goto :FORMAT
REM If no eMMC disk exists,then use SSD/HDD(SATA interface only)
for /l %%i in (3,-1,0) do (
echo select disk %%i > x:detdisk.txt
echo detail disk >> x:detdisk.txt
diskpart /s x:detdisk.txt > x:det.txt
find /i "Type : SATA" x:det.txt
if not errorlevel 1 set Disk=%%i
)
if not defined Disk echo Cannot find a fixed internal disk. && goto :ERROR
:FORMAT
echo.
echo Using disk %Disk%
echo.
echo select disk "%Disk%" > x:winpart.txt
echo clean >> x:winpart.txt
echo convert gpt >> x:winpart.txt
echo create partition efi size=100 >> x:winpart.txt
echo format quick fs=fat32 label="System" >> x:winpart.txt
echo assign letter="S" >> x:winpart.txt
echo create partition msr size=16 >> x:winpart.txt
echo create partition primary >> x:winpart.txt
echo format quick fs=ntfs label="Windows" >> x:winpart.txt
echo assign letter="W" >> x:winpart.txt
echo shrink desired=1000 >> x:winpart.txt
echo create partition primary >> x:winpart.txt
echo format quick fs=ntfs label="Recovery" >> x:winpart.txt
echo assign letter="R" >> x:winpart.txt
echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac" >> x:winpart.txt
echo gpt attributes=0×8000000000000001 >> x:winpart.txt
echo exit >> x:WinPart.txt
echo Winpart.txt now contains…..
echo.
type x:winpart.txt
echo.
echo diskpart /s x:winpart.txt
diskpart /s x:winpart.txt
ping 127.0.0.1 -n 5 > x:delay.txt
if not exist W: echo Diskpart failed to format disk. && goto :ERROR
echo.
echo Making directories…
echo w:recyclerscratch
echo r:recoverywindowsre
md w:recyclerscratch
if errorlevel 1 echo Failed to make w:recyclerscratch directory && goto :ERROR
md r:recoverywindowsre
if errorlevel 1 echo Failed to make r:recoverywindowsre directory && goto :ERROR
echo.
echo Applying image to Windows partition
if /i "%IMAGETYPE%"=="WIM" (
DISM /Apply-Image /ImageFile:%WinPESource%imagesinstall.wim /Index:1 /ApplyDir:w: /Compact /EA /ScratchDir:w:recyclerSCRATCH
if errorlevel 1 echo Failed to apply image. && goto :ERROR
) else (
DISM /Apply-Image /ImageFile:%WinPESource%imagesinstall.swm /SwmFile:%WinPESource%imagesinstall*.swm /Index:1 /ApplyDir:w: /Compact /EA /ScratchDir:w:recyclerSCRATCH
if errorlevel 1 echo Failed to apply image. && goto :ERROR
)
echo.
echo Moving WinRE to Recovery Partition
attrib w:WindowsSystem32recoverywinre.wim -s -h -a -r
move w:WindowsSystem32recoverywinre.wim r:recoverywindowsre
if errorlevel 1 echo Failed to move winre.wim to R:recoverywindowsre && goto :ERROR
attrib r:RecoveryWindowsrewinre.wim +s +h +a +r
echo.
echo Setting BCD on EFI partition
echo W:WINDOWSSYSTEM32BCDBOOT w:WINDOWS /s s: /f all
W:WINDOWSSYSTEM32BCDBOOT w:WINDOWS /s s: /f all
if errorlevel 1 echo Failed to set BCD on EFI partition. && goto :ERROR
echo.
echo Setting hardware recovery button for BIOS trigger
echo.
md S:EFIRecovery
xcopy /e /h S:EFIMicrosoft* S:EFIRecovery
del /a S:EFIRecoveryBootBCD
del /a S:EFIRecoveryBootBCD.LOG
bcdedit /createstore S:BCD
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
bcdedit /store S:BCD /create {bootmgr} /d "Windows Boot Manager"
bcdedit /store S:BCD /set {bootmgr} device partition=S:
bcdedit /store S:BCD /set {bootmgr} locale en-US
bcdedit /store S:BCD /set {bootmgr} integrityservices Enable
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
bcdedit /store S:BCD /create {11111111-1111-1111-1111-111111111111} /d "Windows Recovery" /device
bcdedit /store S:BCD /set {11111111-1111-1111-1111-111111111111} ramdisksdidevice partition=R:
bcdedit /store S:BCD /set {11111111-1111-1111-1111-111111111111} ramdisksdipath RecoveryWindowsREboot.sdi
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
bcdedit /store S:BCD /create {22222222-2222-2222-2222-222222222222} /d "Windows Recovery Environment" /application osloader
bcdedit /store S:BCD /set {bootmgr} default {22222222-2222-2222-2222-222222222222}
bcdedit /store S:BCD /set {bootmgr} displayorder {22222222-2222-2222-2222-222222222222}
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
bcdedit /store S:BCD /set {default} device ramdisk=[R:]RecoveryWindowsREwinre.wim,{11111111-1111-1111-1111-111111111111}
bcdedit /store S:BCD /set {default} path WindowsSystem32winload.efi
bcdedit /store S:BCD /set {default} locale en-US
bcdedit /store S:BCD /set {default} displaymessage "Recovery"
bcdedit /store S:BCD /set {default} osdevice ramdisk=[R:]RecoveryWindowsREwinre.wim,{11111111-1111-1111-1111-111111111111}
bcdedit /store S:BCD /set {default} systemroot Windows
bcdedit /store S:BCD /set {default} nx OptIn
bcdedit /store S:BCD /set {default} bootmenupolicy Standard
bcdedit /store S:BCD /set {default} winpe Yes
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
xcopy /h S:BCD* S:EFIRecoveryBoot
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
del /a S:BCD*
if %errorlevel% NEQ 0 echo Failed to set recovery information in efi && goto :ERROR
echo.
echo Updating WinRE association
echo w:windowssystem32reagentc /SetREImage /Path r:RECOVERYWINDOWSRE /target w:windows
w:windowssystem32reagentc /SetREImage /Path r:RECOVERYWINDOWSRE /target w:windows
if errorlevel 1 echo Failed to set recovery enviroment. && goto :ERROR
echo.
echo Copying test tool and customization files
::echo.
::echo xcopy %WinPESource%ScriptsTEST_TOOL W:TEST_TOOL /e /i /y
::xcopy %WinPESource%ScriptsTEST_TOOL W:TEST_TOOL /e /i /y
echo.
echo xcopy %WinPESource%oemScriptsoobeInfo w:WindowsSystem32oobeInfo /e /y /i
xcopy %WinPESource%oemScriptsoobeInfo w:WindowsSystem32oobeInfo /e /y /i
echo.
echo xcopy %WinPESource%OEM w:RECOVERYOEM /y /e /i
xcopy %WinPESource%OEM w:RECOVERYOEM /y /e /i
echo.
echo copy %WinPESource%ScriptsUnattend.xml w:WindowsPanther /y
copy %WinPESource%ScriptsUnattend.xml w:WindowsPanther /y
echo.
echo copy %WinPESource%oemScriptscsup.txt w:Windows /y
copy %WinPESource%oemScriptscsup.txt w:Windows /y
echo.
echo copy %WinPESource%oemScriptswin.txt w:Windowssystem32 /y
copy %WinPESource%oemScriptswin.txt w:Windowssystem32 /y
echo.
echo copy %WinPESource%oemScriptsoemlogo.bmp w:WindowsPanther /y
copy %WinPESource%oemScriptsoemlogo.bmp w:WindowsPanther /y
echo.
echo copy %WinPESource%oemScriptsoembackground.jpg w:Windowswebwallpaper /y
copy %WinPESource%oemScriptsoembackground.jpg w:Windowswebwallpaper /y
echo.
echo copy %WinPESource%oemScriptsLayoutModification.xml W:UsersDefaultAppDataLocalMicrosoftWindowsShell /y
copy %WinPESource%oemScriptsLayoutModification.xml W:UsersDefaultAppDataLocalMicrosoftWindowsShell /y
echo.
echo Writing image SN to C:RECOVERYOEMImageSN.txt
echo TD-JX-116-SF133GR300-GA60A-193-A-user>w:RECOVERYOEMImageSN.txt
rd /s /q w:recycler
echo.
echo ****************************************************
echo Image deployment COMPLETED. Type EXIT to reboot.
echo Type WPEUTIL SHUTDOWN to shutdown the system.
echo ****************************************************
goto END
:ERROR
echo.
echo *************************************************************
echo An error has been detected,the procedure cannot continue.
echo *************************************************************
:END