@echo off
cls
color 0F
title Rev:1.15.1229
@rem Auther:yuxin
@rem =======================
@rem =======================
@rem =======================
@rem
@rem **************************************************
@rem 刷bios时:FLASH_BIOS=1
@rem **************************************************
@rem
set FLASH_BIOS=0
@rem
@rem **************************************************
@rem 双系统刷单系统时:OnlySingleOS=1
@rem **************************************************
@rem
set OnlySingleOS=0
@rem
@rem **************************************************
@rem 1.自定义C盘大小时:SpecifyCSize=xx
@rem (注:这里指定C盘容量,单位是:GB)
@rem 2.自定义C盘名称时:SpecifyCName=xxx
@rem (注:默认C盘名称是:Windows)
@rem **************************************************
@rem
set /a SpecifyCSize=0
set SpecifyCName=Windows
@rem
@rem **************************************************
@rem 1.创建D盘时:CreateTwoPartitions=1
@rem (注:创建D盘时,必须要指定C盘大小)
@rem 2.自定义D盘名称时:SpecifyDName=xxx
@rem (注:默认D盘名称是:UserData)
@rem 3.if install TestImage:
@rem 1) Exist images\TestImage.wim
@rem 2) Exist images\Test\*
@rem **************************************************
@rem
set CreateTwoPartitions=0
set SpecifyDName=UserData
@rem
@rem **************************************************
@rem 1.做一键恢复时:OneKeyRecovery=1
@rem 2.自定义R盘名称时:SpecifyRName=xxx
@rem (注:默认是IP3_RECV,不可为空)
@rem 3.自定义R盘恢复路径时:OneKeyPath=xx\xx\xx
@rem (注:默认是EFI\OEM)
@rem **************************************************
@rem
set OneKeyRecovery=0
set SpecifyRName=IP3_RECV
set OneKeyPath=EFI\OEM
@rem
@rem =======================
@rem =======================
@rem =======================
@rem
@rem *******************************************************************
@rem !!!!!!!!! The following content Don't Modified !!!!!!!!!
@rem *******************************************************************
@echo Running USB2-Main Script
call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
@rem create diskpart script for list disk
set TestMode=0
@echo.>x:\listdisks.txt
@echo list disk>>x:\listdisks.txt
@echo exit>>x:\listdisks.txt
@echo.
diskpart /s x:\listdisks.txt>x:\Disks.txt
@rem Set Disk equal to blank to start
set Disk=
@rem *****************************************************************
@rem This line will write a diskpart script to select the disk and detail it's contents.
@rem We use this output to find a disk that does NOT have Winpe as the volume label.
@rem That disk will have the OS installed to it. This way you can exclude USB from diskpart.
@rem
@rem This works around the issue where the USB key is sometimes enumerated as disk 0 and the
@rem SSD is disk 1.
@rem *****************************************************************
@rem if exist emmc disk, winpe will disk 1
for /f "skip=8 tokens=2" %%A in (x:\Disks.txt) do (
@echo sel disk %%A>x:\Par.txt
@echo det disk>>x:\Par.txt
@echo exit>>x:\Par.txt
if NOT "%%A"=="DiskPart…" call :ListPar %%A
)
if %Disk%=="" echo. No disk found without a volume label of "Winpe"&& set disk=0
@echo Using Disk "%Disk%"
@echo.
@echo *****************************************************************
@echo Map drive letter for WinPE:\Images folder
@echo *****************************************************************
@rem Create an output file containing all the drive letters
@echo.>x:\Volumes.txt
@echo list volume>>x:\Volumes.txt
@echo exit>>x:\Volumes.txt
@echo.
diskpart /s x:\volumes.txt>%WinPESource%Output.txt
@rem Go through each drive letter, looking for the images\ folder
for /f "skip=8 tokens=3" %%A in (%WinPESource%Output.txt) do (
if exist %%A:\images\ set InstallPath=%%A:\images&& echo "Found device with images folder "
)
@echo.
@echo *****************************************************************
@echo Map drive letter for Install.wim and Winre.wim
@echo *****************************************************************
setlocal enabledelayedexpansion
cd /d %InstallPath%
for /f "delims=" %%i in ('dir /a-d /b *.wim') do (
set /a item+=1
if !item!==1 (
set TARGET_WIM1=%%i
set WIM1_SIZE=%%~zi
)
if !item!==2 (
set TARGET_WIM2=%%i
set WIM2_SIZE=%%~zi
)
if !item!==3 (
@echo More than two *.wim file in this directory !
goto :error
)
)
if %item%==1 (
if %WIM1_SIZE:~0,-6% GTR 2048 (
set WIM_FILE=%TARGET_WIM1%
set /a WIM_FILE_SIZE=%WIM1_SIZE:~0,-6%
set RE_FILE=NO
set /a RE_FILE_SIZE=0
) else (
@echo "%TARGET_WIM1% is not valid install.wim !"
goto :error
)
)
if %item%==2 (
@rem get which one is install.wim or winre.wim
set WIM_FILE=%TARGET_WIM1%
set /a WIM_FILE_SIZE=%WIM1_SIZE:~0,-6%
set RE_FILE=%TARGET_WIM2%
set /a RE_FILE_SIZE=%WIM2_SIZE:~0,-6%
if %WIM1_SIZE:~0,-6% LSS 2048 (
set WIM_FILE=%TARGET_WIM2%
set /a WIM_FILE_SIZE=%WIM2_SIZE:~0,-6%
set RE_FILE=%TARGET_WIM1%
set /a RE_FILE_SIZE=%WIM1_SIZE:~0,-6%
)
)
@echo WIM_FILE1 is:%WIM_FILE%
@echo WIM_FILE2 is:%RE_FILE%
set /a MySize=1024 * %SpecifyCSize%
@rem get the install.wim is win8.1 or win10
powershell get-WindowsImage -ImagePath %InstallPath%\%WIM_FILE% -index 1 | find "10.0" || (
powershell get-WindowsImage -ImagePath %InstallPath%\%WIM_FILE% -index 1 | find "6.3.9600" || (
@echo Unknown image ! ! !
goto :error
)
@echo This is Win8.1 image !
if %RE_FILE%==NO echo "Not found Winre.wim in images\"&& goto :error
set WINX_IMAGE=Win8_OS
set /a RECOVERY_SIZE=%WIM_FILE_SIZE%+%RE_FILE_SIZE%+50
goto :CheckupOS
)
@echo This is Win10 image !
set WINX_IMAGE=Win10_OS
if /i %WIM_FILE%==TestImage.wim (
@echo.
@echo Found TestImage.wim at: %InstallPath%
@echo.
set TestMode=1
set /a TEST_IMAGE_SIZE=%WIM_FILE_SIZE%+100
)
if %RE_FILE_SIZE% LSS 430 set /a RECOVERY_SIZE=480
if %RE_FILE_SIZE% GEQ 430 (
if %RE_FILE_SIZE% LSS 680 (
set /a RECOVERY_SIZE=%RE_FILE_SIZE%+320
) else (
set /a RECOVERY_SIZE=%RE_FILE_SIZE%+1024
)
)
goto :CheckupOS
:CheckupOS
@echo.
@echo The image is: %WINX_IMAGE%
@echo The recovery partition size:%RECOVERY_SIZE%
@echo *****************************************************************
@echo Checkup SingleOS or DualOS or whether exist windows partiton
@echo *****************************************************************
@rem create diskpart script for search windows partitions from emmc disk
@echo.>x:\EmmcDisk.txt
@echo select disk "%Disk%" >>x:\EmmcDisk.txt
@echo list partition >>x:\EmmcDisk.txt
@echo exit >>x:\EmmcDisk.txt
diskpart /s x:\EmmcDisk.txt>x:\EmmcPartitions.txt
@echo.
@rem check the device is whether DualOS ,if not:create singleOS partition
set MyOS=
@rem Only install single os ,check the switch
if %OnlySingleOS%==1 set MyOS=Win_SingleOS&& goto :SingleOSPartition
find "Partition 10" x:\EmmcPartitions.txt >nul
if NOT %errorlevel%==0 set MyOS=Win_SingleOS&& goto :SingleOSPartition
set MyOS=Win_DualOS
@rem Hide the android volume
@echo. >x:\HideAndroidVol.txt
@echo select disk "%Disk%">>x:\HideAndroidVol.txt
for /f "tokens=2" %%i in ('type x:\VolumeList.txt ^| find "RAW"') do (
@echo Select Volume %%i >>x:HideAndroidVol.txt
@echo attributes volume set hidden >>x:HideAndroidVol.txt
)
@echo call diskpart /s x:HideAndroidVol.txt
diskpart /s x:HideAndroidVol.txt
@rem Checkup windows partitions,and delete them
@echo. >x:\windowsPartitions.txt
@echo. >x:\DeletePartitions.txt
@echo select disk "%Disk%">>x:\windowsPartitions.txt
@echo select disk "%Disk%">>x:\DeletePartitions.txt
for /f "skip=1 tokens=2" %%i in ('type x:\EmmcPartitions.txt ^| find "Partition"') do (
@echo select disk "%Disk%">x:\windowsPartitions.txt
@echo select Partition %%i>>x:\windowsPartitions.txt
@echo detail partition >>x:\windowsPartitions.txt
@echo exit >>x:\windowsPartitions.txt
diskpart /s x:\windowsPartitions.txt>x:\PartitionDetails.txt
if %ERRORLEVEL% NEQ 0 echo Diskpart error && goto :Error
type x:\PartitionDetails.txt | find "* Volume" >x:\VolPro.txt
for /f "tokens=3" %%j in ('type x:\VolPro.txt ^| find /v "ESP" ^| find /v "WINPE" ^| find /v "RAW"') do (
@echo select disk "%Disk%">x:\DeletePartitions.txt
@echo select partition %%i >>x:\DeletePartitions.txt
@echo delete Partition override >>x:\DeletePartitions.txt
@echo exit >>x:\DeletePartitions.txt
diskpart /s x:\DeletePartitions.txt
)
)
@echo.
goto
ualOSPartition
:SingleOSPartition
@echo SingleOS device !
@echo.
@echo *****************************************************************
@echo Create disk partition script for SingleOS
@echo *****************************************************************
REM this disk partition for Normal single OS
@echo.>x:\wimpart.txt
@echo select disk "%Disk%">>x:\wimpart.txt
@echo clean>>x:\wimpart.txt
@echo convert gpt>>x:\wimpart.txt
@echo create partition efi size=100>>x:\wimpart.txt
@echo format quick fs=fat32 label="System">>x:\wimpart.txt
@echo assign letter="S">>x:\wimpart.txt
@echo create partition msr size=128>>x:\wimpart.txt
if %MySize%==0 (
@echo create partition primary>>x:\wimpart.txt
@echo shrink minimum=%RECOVERY_SIZE%>>x:\wimpart.txt
@echo format quick fs=ntfs label="%SpecifyCName%">>x:\wimpart.txt
@echo assign letter="W">>x:\wimpart.txt
@echo create partition primary>>x:\wimpart.txt
) else (
@echo create partition primary size=%MySize%>>x:\wimpart.txt
@echo format quick fs=ntfs label="%SpecifyCName%">>x:\wimpart.txt
@echo assign letter="W">>x:\wimpart.txt
if %CreateTwoPartitions%==1 (
if %TestMode%==1 (
@echo create partition primary size=%TEST_IMAGE_SIZE%>>x:\wimpart.txt
@echo format quick fs=ntfs label="RecoveryImage">>x:\wimpart.txt
@echo assign letter="M">>x:\wimpart.txt
)
@echo create partition primary>>x:\wimpart.txt
@echo shrink minimum=%RECOVERY_SIZE%>>x:\wimpart.txt
@echo format quick fs=ntfs label="%SpecifyDName%">>x:\wimpart.txt
@echo assign letter="U">>x:\wimpart.txt
@echo create partition primary>>x:\wimpart.txt
) else (
@echo create partition primary size=%RECOVERY_SIZE%>>x:\wimpart.txt
)
)
@echo format quick fs=ntfs label="%SpecifyRName%">>x:\wimpart.txt
@echo assign letter="R">>x:\wimpart.txt
@echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\wimpart.txt
@echo gpt attributes=0×8000000000000001>>x:\wimpart.txt
@echo.
@echo Wimpart.txt is created !
type x:\wimpart.txt
@echo.
@echo *****************************************************************
@echo Setting up the partition table
@echo *****************************************************************
@echo call diskpart /s x:\wimpart.txt
diskpart /s x:\wimpart.txt
@echo.
goto :ApplyOS
ualOSPartition
@echo DualOS device !
@echo.
@echo *****************************************************************
@echo Create disk partition script for DualOS
@echo *****************************************************************
REM this disk partition for insyde bios
@echo.>x:\wimpart.txt
@echo select disk "%Disk%" >>x:\wimpart.txt
@echo create partition msr size=128>>x:\wimpart.txt
if %MySize%==0 (
@echo create partition primary>>x:\wimpart.txt
@echo shrink minimum=%RECOVERY_SIZE%>>x:\wimpart.txt
@echo format quick fs=ntfs label="%SpecifyCName%">>x:\wimpart.txt
@echo assign letter="W">>x:\wimpart.txt
@echo create partition primary>>x:\wimpart.txt
) else (
@echo create partition primary size=%MySize%>>x:\wimpart.txt
@echo format quick fs=ntfs label="%SpecifyCName%">>x:\wimpart.txt
@echo assign letter="W">>x:\wimpart.txt
if %CreateTwoPartitions%==1 (
if %TestMode%==1 (
@echo create partition primary size=%TEST_IMAGE_SIZE%>>x:\wimpart.txt
@echo format quick fs=ntfs label="RecoveryImage">>x:\wimpart.txt
@echo assign letter="M">>x:\wimpart.txt
)
@echo create partition primary>>x:\wimpart.txt
@echo shrink minimum=%RECOVERY_SIZE%>>x:\wimpart.txt
@echo format quick fs=ntfs label="%SpecifyDName%">>x:\wimpart.txt
@echo assign letter="U">>x:\wimpart.txt
@echo create partition primary>>x:\wimpart.txt
) else (
@echo create partition primary size=%RECOVERY_SIZE%>>x:\wimpart.txt
)
)
@echo format quick fs=ntfs label="%SpecifyRName%">>x:\wimpart.txt
@echo assign letter="R">>x:\wimpart.txt
@echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\wimpart.txt
@echo gpt attributes=0×8000000000000001>>x:\wimpart.txt
@echo exit>>x:\wimpart.txt
@echo.
@echo Wimpart.txt is created !
type x:\wimpart.txt
@echo.
@echo *****************************************************************
@echo Setting up the partition table
@echo *****************************************************************
@echo call diskpart /s x:\wimpart.txt
diskpart /s x:\wimpart.txt
@echo.
goto :ApplyOS
:ApplyOS
@echo *****************************************************************
@echo Create folders on EMMC partition
@echo *****************************************************************
if /i %PROCESSOR_ARCHITECTURE%==x86 set zipTool="7za_x86.exe"
if /i %PROCESSOR_ARCHITECTURE%==amd64 set zipTool="7za_x64.exe"
@echo md w:\recycler\scratch
md w:\recycler\scratch
if not %errorlevel% == 0 echo "Failed to make w:\recycler\scratch directory" && goto :error
@echo md R:\recovery\windowsre
md R:\recovery\windowsre
if not %errorlevel% == 0 echo "Failed to make R:\recovery\windowsre directory" && goto :error
set BCDFILE="R:\%OneKeyPath%\Boot\BCD"
if %OneKeyRecovery%==1 (
@echo md R:\%OneKeyPath%
md "R:\%OneKeyPath%"
if not %errorlevel% == 0 echo "Failed to make R:\%OneKeyPath% directory" && goto :error
call "%WinpeSource%Scripts\%zipTool%" x "%WinpeSource%Scripts\MyBoot.zip" -o"R:\%OneKeyPath%\"
if not %errorlevel% == 0 echo "Fail to Extract MyBoot.zip to R:\%OneKeyPath%" && goto :error
if exist %BCDFILE% del %BCDFILE% /f /q
bcdedit /createstore %BCDFILE%
if not %errorlevel% == 0 echo "ERROR0:create BCD file" && goto :error
bcdedit /store %BCDFILE% /create {bootmgr} /d "Windows Boot Manager"
if not %errorlevel% == 0 echo "ERROR1:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {bootmgr} device partition=R:
if not %errorlevel% == 0 echo "ERROR2:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {bootmgr} locale en-US
if not %errorlevel% == 0 echo "ERROR3:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {bootmgr} integrityservices Enable
if not %errorlevel% == 0 echo "ERROR4:create BCD file" && goto :error
bcdedit /store %BCDFILE% /create {11111111-1111-1111-1111-111111111111} /d "Windows OneKey Recovery" /device
if not %errorlevel% == 0 echo "ERROR5:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {11111111-1111-1111-1111-111111111111} ramdisksdidevice partition=R:
if not %errorlevel% == 0 echo "ERROR6:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {11111111-1111-1111-1111-111111111111} ramdisksdipath \%OneKeyPath%\Boot\boot.sdi
if not %errorlevel% == 0 echo "ERROR7:create BCD file" && goto :error
bcdedit /store %BCDFILE% /create {22222222-2222-2222-2222-222222222222} /d "Windows Recovery Environment" /application osloader
if not %errorlevel% == 0 echo "ERROR8:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {bootmgr} default {22222222-2222-2222-2222-222222222222}
if not %errorlevel% == 0 echo "ERROR9:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {bootmgr} displayorder {22222222-2222-2222-2222-222222222222}
if not %errorlevel% == 0 echo "ERROR10:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} device ramdisk=[R:]\recovery\windowsre\winre.wim,{11111111-1111-1111-1111-111111111111}
if not %errorlevel% == 0 echo "ERROR11:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} path \Windows\System32\winload.efi
if not %errorlevel% == 0 echo "ERROR12:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} locale en-US
if not %errorlevel% == 0 echo "ERROR13:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} displaymessage "Recovery"
if not %errorlevel% == 0 echo "ERROR14:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} osdevice ramdisk=[R:]\recovery\windowsre\winre.wim,{11111111-1111-1111-1111-111111111111}
if not %errorlevel% == 0 echo "ERROR15:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} systemroot \Windows
if not %errorlevel% == 0 echo "ERROR16:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} nx OptIn
if not %errorlevel% == 0 echo "ERROR17:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} bootmenupolicy Standard
if not %errorlevel% == 0 echo "ERROR18:create BCD file" && goto :error
bcdedit /store %BCDFILE% /set {default} winpe Yes
if not %errorlevel% == 0 echo "ERROR19:create BCD file" && goto :error
if not exist %BCDFILE% echo "Fail to create BCD file" && goto :error
)
@echo.
if %WINX_IMAGE% == Win10_OS (
@rem xcopy winre.wim
@echo *****************************************************************
@echo Backup Winre.wim to R:\recovery\windowsre
@echo *****************************************************************
if EXIST w:\Windows\System32\recovery\winre.wim (
@echo move w:\Windows\System32\recovery\winre.wim r:\recovery\windowsre
move w:\Windows\System32\recovery\winre.wim r:\recovery\windowsre
if %errorlevel% NEQ 0 echo "Failed to move winre.wim to r:\recovery\windowsre" && goto :error
)
if NOT EXIST w:\Windows\System32\recovery\winre.wim (
@echo xcopy %InstallPath%\Winre.wim r:\recovery\windowsre /y
xcopy %InstallPath%\Winre.wim r:\recovery\windowsre /y
if %errorlevel% NEQ 0 echo "Failed to copy images\winre.wim to r:\recovery\windowsre" && goto :error
)
@echo.
@echo *****************************************************************
@echo Applying the image from U-Disk
@echo *****************************************************************
rem copy testImage to m:\
if %TestMode%==1 (
if not exist "%InstallPath%\TestImage.wim" echo "Not found %InstallPath%\TestImage.wim" && goto :error
@echo copy %InstallPath%\TestImage.wim M:\
@echo Please waiting …
xcopy "%InstallPath%\TestImage.wim" M:\ /y
if not %errorlevel% == 0 echo "Failed to copy TestImage.wim to M:\" && goto :error
@echo DISM /Apply-Image /ImageFile:"M:\TestImage.wim" /ApplyDir:w: /Index:1 /ScratchDir:w:\recycler\SCRATCH
DISM /Apply-Image /ImageFile:"M:\TestImage.wim" /ApplyDir:w: /Index:1 /ScratchDir:w:\recycler\SCRATCH
if not %errorlevel% == 0 echo "Failed to apply image to w:" && goto :error
@echo.
) else (
@echo DISM /Apply-Image /ImageFile:"%InstallPath%\%WIM_FILE%" /ApplyDir:w: /Index:1 /Compact /ScratchDir:w:\recycler\SCRATCH
DISM /Apply-Image /ImageFile:"%InstallPath%\%WIM_FILE%" /ApplyDir:w: /Index:1 /Compact /ScratchDir:w:\recycler\SCRATCH
if not %errorlevel% == 0 echo "Failed to apply image to w:" && goto :error
@echo.
)
goto :Win10_Files
)
if %WINX_IMAGE% == Win8_OS (
@echo R:\"windows images"
md R:\"windows images"
if not %errorlevel% == 0 echo "Failed to make R:\windows images directory" && goto :error
@echo.
@echo *****************************************************************
@echo Backup Install.wim and Winre.wim to R:\
@echo *****************************************************************
@echo.
@rem xcopy winre.wim
@echo copy %InstallPath%\winre.wim R:\recovery\windowsre
@echo Please waiting …
copy %InstallPath%\winre.wim R:\recovery\windowsre
if not %errorlevel% == 0 echo "Failed to copy winre.wim to R:\recovery\windowsre" && goto :error
@echo.
rem xcopy install.wim
@echo copy %InstallPath%\%WIM_FILE% R:\"windows images\install.wim"
@echo Please waiting …
echo f|xcopy %InstallPath%\%WIM_FILE% R:\"windows images\install.wim" /y
if not %errorlevel% == 0 echo "Failed to copy install.wim to R:\Windows images" && goto :error
@echo.
@echo *****************************************************************
@echo Applying the WIMboot image from R:\
@echo *****************************************************************
@echo.
@echo DISM /Apply-Image /ImageFile:"R:\windows images\install.wim" /ApplyDir:w: /Index:1 /WIMBoot /ScratchDir:w:\recycler\SCRATCH
DISM /Apply-Image /ImageFile:"R:\windows images\install.wim" /ApplyDir:w: /Index:1 /WIMBoot /ScratchDir:w:\recycler\SCRATCH
if not %errorlevel% == 0 echo "Failed to apply image to w:" && goto :error
@echo.
)
@echo.
goto :EndStep
:Win10_Files
@echo.
IF EXIST %InstallPath%\*.ppkg (
@echo *****************************************************************
@echo Copying over NON Scanstate Packages, if they exist.
@echo IF YOU COPY OVER SCANSTATE PPKG, THIS CAUSE IMAGE TO FAIL DURING RECOVERY
@echo *****************************************************************
@echo xcopy %InstallPath%\*.ppkg w:\Recovery\Customizations /y
xcopy %InstallPath%\*.ppkg w:\Recovery\Customizations\ /y
@echo Apply PPKG
setlocal enabledelayedexpansion
set PPKG_PATH=w:\Recovery\Customizations
cd /d %PPKG_PATH%
set num=""
for /f "delims=" %%i in ('dir /a-d /b *.ppkg') do (
set /a num+=1
if "!num!" == "!num!" (
@echo if /i "%%~ni"=="usmt" DISM /Apply-CustomDataImage /CustomDataImage:!PPKG_PATH!\%%~ni.ppkg /ImagePath:w:\ /SingleInstance
if /i "%%~ni"=="usmt" DISM /Apply-CustomDataImage /CustomDataImage:!PPKG_PATH!\%%~ni.ppkg /ImagePath:w:\ /SingleInstance
@echo if /i NOT "%%~ni"=="usmt" DISM.exe /Image:w:\ /Add-ProvisioningPackage /PackagePath:!PPKG_PATH!\%%~ni.ppkg
if /i NOT "%%~ni"=="usmt" DISM.exe /Image:w:\ /Add-ProvisioningPackage /PackagePath:!PPKG_PATH!\%%~ni.ppkg
)
)
)
@echo.
goto :EndStep
:EndStep
@echo *****************************************************************
@echo Setting the boot environment
@echo *****************************************************************
if %MyOS% == Win_SingleOS (
@echo call w:\WINDOWS\SYSTEM32\BCDBOOT w:\WINDOWS /s S: /f all
w:\WINDOWS\SYSTEM32\BCDBOOT w:\WINDOWS /s S: /f all
)
if %MyOS% == Win_DualOS (
@echo call w:\WINDOWS\SYSTEM32\BCDBOOT w:\WINDOWS
w:\WINDOWS\SYSTEM32\BCDBOOT w:\WINDOWS
)
if not %errorlevel% == 0 echo "Failed to set boot environment" && goto :error
@echo.
@echo *****************************************************************
@echo Setting the recovery environment
@echo *****************************************************************
@echo w:\windows\system32\reagentc /SetREImage /Path R:\recovery\windowsre /target w:\windows
w:\windows\system32\reagentc.exe /SetREImage /Path R:\recovery\windowsre /target w:\windows
if not %errorlevel% == 0 echo "Failed to set recovery environment!" && goto :error
@echo.
@echo *****************************************************************
@echo Copying over Audit\Unattend.xml to use on factory floor if it exists
@echo *****************************************************************
if EXIST %InstallPath%\Audit\Unattend.xml (
@echo xcopy %InstallPath%\Audit\Unattend.xml w:\Windows\Panther /y
if exist w:\Windows\Panther\Unattend.xml rename w:\Windows\Panther\Unattend.xml temp.xml
xcopy %InstallPath%\Audit\Unattend.xml w:\Windows\Panther /y
)
if EXIST %InstallPath%\DefaultLayouts.xml (
@echo xcopy %InstallPath%\DefaultLayouts.xml w:\Users\Default\AppData\Local\Microsoft\Windows\Shell\ /y
xcopy %InstallPath%\DefaultLayouts.xml w:\Users\Default\AppData\Local\Microsoft\Windows\Shell\ /y
)
if EXIST %InstallPath%\LayoutModification.xml (
@echo xcopy %InstallPath%\LayoutModification.xml w:\Users\Default\AppData\Local\Microsoft\Windows\Shell\ /y
xcopy %InstallPath%\LayoutModification.xml w:\Users\Default\AppData\Local\Microsoft\Windows\Shell\ /y
)
if EXIST %InstallPath%\Recovery\* (
@echo xcopy %InstallPath%\Recovery\* w:\Recovery\OEM\Backup\ /ey
xcopy %InstallPath%\Recovery\* w:\Recovery\OEM\Backup\ /ey
)
rem Just for testMOde
if EXIST %InstallPath%\TEST\* (
@echo xcopy %InstallPath%\TEST\* U:\TEST\ /ey
xcopy %InstallPath%\TEST\* U:\TEST\ /ey
)
@echo.
@echo *****************************************************************
@echo Copy over Test tools to w:\
@echo *****************************************************************
@echo %WinpeSource%Scripts\%zipTool% x w:\TEST_TOOL.zip -oW:\
if EXIST %WinpeSource%TEST_TOOL.zip %WinpeSource%Scripts\%zipTool% x %WinpeSource%TEST_TOOL.zip -oW:\
@echo.
if "%FLASH_BIOS%"=="1" GOTO :FLASH_BIOS
goto :END
:FLASH_BIOS
@echo.
@echo *****************************************************************
@echo Flash BIOS
@echo *****************************************************************
@echo.
cd /d %WinpeSource%BIOS
call flashbsn.cmd
cd\
@echo.
@echo *****************************************************************
@echo Flash BIOS completed !
@echo *****************************************************************
goto :END
:ERROR
COLOR 4F
@echo.
@echo.
@echo An error has been detected.
@echo.
@echo.
goto :EOF
:ListPar
@REM This section is to bring a disk number and use it to List Partitions
@echo.
set TempDisk=%1
diskpart /s x:\Par.txt>x:\ParOutput.txt
for /f "skip=24 tokens=3" %%A in (x:\ParOutput.txt) do (
if /i "%%A"=="no" set Disk=%TempDisk%
)
for /f "skip=26 tokens=4" %%A in (x:\ParOutput.txt) do (
if /i NOT "%%A"=="Winpe" set Disk=%TempDisk%
)
goto :EOF
:END
if exist "w:\recycler" rmdir /s /q w:\recycler
if exist "w:\sources" rmdir /s /q w:\sources
if exist %WinpeSource%lang.txt del %WinpeSource%lang.txt
if exist %WinpeSource%Output.txt del %WinpeSource%Output.txt
@echo.
@echo *****************************************************************
@echo It has been completed ,input EXIT for rebooting from c:\
@echo *****************************************************************
@rem Get finish time so we can evaluate total WinPE phase time.
call |time>x:\StopTime.txt
@echo.
@rem Now parse both files to display the Start and Finish Time
for /f "tokens=5" %%A in (x:\starttime.txt) do echo Script Start Time is %%A
for /f "tokens=5" %%A in (x:\stoptime.txt) do echo Script Stop Time is %%A
@echo.
exit