WINPE镜像制作-startnet.cmd详解

一、WINPE制作

1、预习http://blog.csdn.net/greless/article/details/51564915

2.流程如下

管理员模式进入部署与映像工具环境

1)copype amd64 C:\WinPE_amd64(复制ADK包WINPE系统)

2)Dism /mount-image /imagefile:C:\WinPE_amd64\media\sources\boot.wim /index:1 /mountdir:C:\winpe_amd64\mount(加载镜像)

重点:此刻映像安装完成,startnet.cmd放入 C:\WinPE_amd64\mount\Windows\System32,WINPE系统会自动识别该脚本 

3)Dism /unmount-image /mountdir:C:\winpe_amd64\mount /commit(卸载镜像)

4)MakeWinPEMedia /ISO C:\WinPE_amd64 C:\WinPE_amd64\WinPE_amd64.iso(制作ISO)

二、startnet.cmd制作

1、该脚本定位到U盘镜像盘\Scripts\main.cmd,后面只需要随时修改main.cmd脚本即可。

2、为什么不能随时修改startnet.cmd?

startnet.cmd已经跟随WINPE系统了,要修改除非改镜像,然后又重新刻录到U盘。

@ECHO off
@REM 
@REM  Capture the START time so we can evaluate total WinPE phase time.
@REM
@ECHO Starting timer...
CALL |time>x:\starttime.txt
@ECHO.
@REM Initialize WinPE
@ECHO wpeinit
WPEINIT
@ECHO.
@ECHO *****************************************************************
@ECHO call wpeutil UpdateBootInfo
WPEUTIL UpdateBootInfo
@ECHO.
SET WinPEREG="HKLM\System\CurrentControlSet\Control"
SET WinPEKey=PEBootRamdiskSourceDrive
SET WinPESource=
@ECHO.
@REM Get volume letter of USB Key
@ECHO for /f "skip=2 tokens=3" %%A in ('call Reg query %WinPEREG% /v %WinPEKEY%') do set WinPESource=%%A
FOR /f "skip=2 tokens=3" %%A IN ('call Reg query %WinPEREG% /v %WinPEKEY%') DO SET WinPESource=%%A
@ECHO WinPESource is drive letter "%WinPESource%"
@ECHO.
@ECHO.
IF "%WinPESource%"=="" ECHO Drive letter NOT found.&& CALL :FINDDRIVE
ECHO WinPESource is "%WinPESource%"

@ECHO *****************************************************************
@ECHO  check if WinPESource==C:\ and change to F:\解决磁盘为空无数据时U盘识别为C盘,造成后面分区C盘已经占领
@ECHO *****************************************************************
set var=C:\
IF   %WinPESource%==%var%  SET WinPESource=F:\&&(
@ECHO. >x:\changedisk.txt
@ECHO list disk >>x:\changedisk.txt
@ECHO list volume >>x:\changedisk.txt
@ECHO select volume 0 >>x:\changedisk.txt
@ECHO assign letter=F noerr>>x:\changedisk.txt
@ECHO list volume  >>x:\changedisk.txt
@ECHO exit>>x:\changedisk.txt
@ECHO.
diskpart /s x:\changedisk.txt
)
@ECHO.
@ECHO.
ECHO WinPESource is "%WinPESource%"
@ECHO.
@ECHO *****************************************************************
@ECHO  Call and run main.cmd on the USB Key
@ECHO *****************************************************************
@ECHO call %WinPESource%Scripts\main.cmd
CALL %WinPESource%Scripts\main.cmd
@ECHO.
@ECHO.
@ECHO *****************************************************************
@ECHO  Prompt to restart or turn off device.
@ECHO *****************************************************************
GOTO :END

:ERROR
@ECHO.
@ECHO An error has been detected.
COLOR 4F
@ECHO. 
GOTO :END

:FINDDRIVE
@ECHO.
@ECHO Trying to find drive letter using diskpart
@ECHO.
@ECHO Lis Vol>x:\FindVol.txt
@ECHO.
@ECHO Running Diskpart to get Volume letters
@ECHO.
DISKPART /s x:\FindVol.txt>x:\VolumeList.txt
@ECHO.
@ECHO Parsing list to find WinPE
@ECHO.
FOR /f "skip=8 tokens=3-4" %%A IN (x:\VolumeList.txt) DO (
@ECHO Checking drive letter %%A has volume label of %%B
IF /i "%%B"=="WINPE" SET WinPESource=%%A
)
SET WinPESource=%WinPESource%:\
GOTO :EOF

:END

下一步学习计划:WINPE镜像制作-main.cmd详解

你可能感兴趣的:(adk,系统部署)