WINPE镜像制作-main.cmd详解
来源:互联网 发布:平板如何下载软件 编辑:程序博客网 时间:2024/06/11 00:47
导读
WINPE镜像制作-startnet.cmd详解
Windows 评估和部署套件 (ADK)系统部署流程
出货系统镜像批量安装方案
一、main.cmd详解
这是一个简单的WINPE脚本,功能为由系统实现自动识别,判定legacy模式安装win7 64 CN,判定uefi安装win8.1 64 CN。
@ECHO off@REM This script is called by x:\Windows\System32\Startnet.cmd - WinPE@ECHO.@ECHO.@ECHO.@ECHO Running Intel Optimization powercfg for improved imaging times@ECHO.@ECHO.@REM *****************************************************************@REM List all the disks, then search the volumes of each one to see @REM which disks may have "Winpe" in the label. We will ignore that @REM disk and use the first disk without the Winpe label that we find. @REM *****************************************************************@REM create diskpart script for list disk@ECHO.>x:\listdisk.txt@ECHO list disk>>x:\listdisk.txt@ECHO exit>>x:\listdisk.txt@ECHO x:\listdisk.txt@ECHO call diskpart /s x:\listdisk.txtCALL diskpart /s x:\listdisk.txt>x:\Disks.txt@ECHO.@REM Set Disk equal to blank to startSET disk=@ECHO.@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 依次取磁盘0,1,2,。。。,1.如果盘符不是WINPE设置disk的值;2.如果不是WINPE又没有磁盘,设置disk=0,后面又要讨论disk 0是否为U盘,为U盘error 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.txtIF NOT "%%A"=="DiskPart..." CALL :LISTPAR %%A)IF "%Disk%"=="" ECHO "No disk found without a volume label of WINPE" && SET disk=0@rem IF "%Disk%"=="" ECHO "No disk found without a volume label of WINPE" && GOTO :ERROR@ECHO Using Disk "%Disk%"@ECHO.@rem if disk is removable, case 1 no disk,case 2 the removable device name is not winPE@ECHO sel disk %Disk% >x:\Par_1.txt@ECHO det disk>>x:\Par_1.txt@ECHO exit>>x:\Par_1.txtCALL DISKPART /S X:\Par_1.txt>X:\ParOutput_1.txtFOR /f "skip=26 tokens=6" %%A IN (x:\ParOutput_1.txt) DO (IF /i "%%A"=="removable" ECHO Disk "%Disk%" is removable device GOTO :ERROR && GOTO :ERROR)@ECHO.@ECHO.@REM *****************************************************************@REM Detect if System is booted into UEFI mode or Bios mode @REM *****************************************************************FOR /f "tokens=2* delims= " %%A IN ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET Firmware=%%B@ECHO.IF %Firmware%==0x1 GOTO :BIOSMODEIF %Firmware%==0x2 GOTO :UEFIMODEGOTO :END:UEFIMODE@ECHO.@REM ************************@REM UEFI SECTION@REM ************************@ECHO The PC is booted in UEFI mode@ECHO.>x:\winpart.txt@ECHO select disk "%Disk%">>x:\winpart.txt@ECHO clean>>x:\winpart.txt@ECHO convert gpt>>x:\winpart.txt@ECHO create partition primary size=300>>x:\winpart.txt@ECHO format quick fs=ntfs label="Windows RE tools">>x:\winpart.txt@ECHO assign letter="T">>x:\winpart.txt@ECHO set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txt@ECHO gpt attributes=0x8000000000000001>>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.txtrem @ECHO create partition msr size=128>>x:\winpart.txt@ECHO create partition primary>>x:\winpart.txtrem @ECHO shrink minimum=15000>>x:\winpart.txt@ECHO format quick fs=ntfs label="Windows">>x:\winpart.txt@ECHO assign letter="C">>x:\winpart.txtrem @ECHO create partition primary>>x:\winpart.txtrem @ECHO format quick fs=ntfs label="Recovery image">>x:\winpart.txtrem @ECHO assign letter="R">>x:\winpart.txtrem @ECHO set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txtrem @ECHO gpt attributes=0x8000000000000001>>x:\winpart.txt@ECHO list partition>>x:\winpart.txt@ECHO list volume>>x:\winpart.txt@ECHO exit>>x:\winpart.txt@ECHO.@REM *****************************************************************@REM Map drive letter for Install.wim@REM *****************************************************************@ECHO.>x:\ListVol.txt@ECHO List volume>>x:\ListVol.txt@ECHO exit>>x:\ListVol.txt@ECHO call diskpart /s x:\ListVol.txtCALL DISKPART /s x:\ListVol.txt>x:\Output.txt@ECHO.@ECHO.@REM Go through each drive letter, looking for the \Scripts\Main.cmd fileFOR /f "skip=8 tokens=3" %%A IN (x:\Output.txt) DO (IF EXIST %%A:\Scripts\Main.cmd SET InstallPath=%%A&& ECHO "Found device with images folder and Main.cmd file")@ECHO call diskpart /s x:\winpart.txtDISKPART /s x:\winpart.txtrem == Apply the image to the Windows partition ==dism /Apply-Image /ImageFile:"%InstallPath%:\Scripts\install_win8_1_x64_UEFI_CN.wim" /Index:1 /ApplyDir:C:\rem == Copy boot files to the System partition ==C:\Windows\System32\bcdboot C:\Windowsrem @ECHO copy %InstallPath%:\Scripts\ApplyImage-UEFI.bat %cd%rem copy %InstallPath%:\Scripts\ApplyImage-UEFI.bat %cd%rem @ECHO ApplyImage-UEFI.bat %InstallPath%:\Scripts\install.wimrem ApplyImage-UEFI.bat %InstallPath%:\Scripts\install.wimGOTO :WINPARTSECTION:BIOSMODE@REM ************************@REM BIOS SECTION@REM ************************@ECHO The PC is booted in BIOS mode@ECHO The PC is booted in BIOS mode>x:\Bios.txt@ECHO.>x:\winpart.txt@ECHO select disk "%Disk%">>x:\winpart.txt@ECHO clean>>x:\winpart.txt@ECHO create partition primary size=100>>x:\winpart.txt@ECHO active>>x:\winpart.txt@ECHO format quick fs=fat32 label="System">>x:\winpart.txt@ECHO assign letter="S">>x:\winpart.txt@ECHO create partition primary>>x:\winpart.txt@ECHO format quick fs=ntfs label="Windows">>x:\winpart.txt@ECHO assign letter="C">>x:\winpart.txtrem @ECHO shrink desired=15000>>x:\winpart.txtrem @ECHO create partition primary>>x:\winpart.txtrem @ECHO format quick fs=ntfs label="Recovery image">>x:\winpart.txtrem @ECHO assign letter="R">>x:\winpart.txtrem @ECHO set id=27>>x:\winpart.txt@ECHO list partition>>x:\winpart.txt@ECHO list volume>>x:\winpart.txt@ECHO exit>>x:\winpart.txt@ECHO.@REM *****************************************************************@REM Map drive letter for Install.wim@REM *****************************************************************@ECHO.>x:\ListVol.txt@ECHO List volume>>x:\ListVol.txt@ECHO exit>>x:\ListVol.txt@ECHO call diskpart /s x:\ListVol.txtCALL DISKPART /s x:\ListVol.txt>x:\Output.txt@ECHO.@ECHO.@REM Go through each drive letter, looking for the \Scripts\Main.cmd fileFOR /f "skip=8 tokens=3" %%A IN (x:\Output.txt) DO (IF EXIST %%A:\Scripts\Main.cmd SET InstallPath=%%A&& ECHO "Found device with images folder and Main.cmd file")@ECHO call diskpart /s x:\winpart.txtDISKPART /s x:\winpart.txtrem == Apply the image to the Windows partition ==dism /Apply-Image /ImageFile:"%InstallPath%:\Scripts\install_win7_x64_legacy_CN.wim" /Index:1 /ApplyDir:C:\rem == Copy boot files to the System partition ==C:\Windows\System32\bcdboot C:\Windowsrem @ECHO copy %InstallPath%:\Scripts\ApplyImage-BIOS.bat %cd%rem copy %InstallPath%:\Scripts\ApplyImage-BIOS.bat %cd%rem @ECHO ApplyImage-BIOS.bat %InstallPath%:\Scripts\install.wimrem ApplyImage-BIOS.bat %InstallPath%:\Scripts\install.wimGOTO :WINPARTSECTION:WINPARTSECTION@ECHO *****************************************************************@ECHO Image deployment COMPLETE. Type EXIT from Command@ECHO *****************************************************************@ECHO.GOTO :REBOOT:LISTPAR@REM This section is to bring a disk number and use it to List Partitions@ECHO.SET TempDisk=%1DISKPART /s x:\Par.txt>x:\ParOutput.txtFOR /f "skip=26 tokens=4" %%A IN (x:\ParOutput.txt) DO (IF /i NOT "%%A"=="Winpe" SET Disk=%TempDisk%)GOTO :EOF:REBOOT@REM @REM Get finish time so we can evaluate total WinPE phase time.@REMCALL |time>x:\StopTime.txt@ECHO.@ECHO Deployment complete, system restart.pauseWPEUTIL REBOOT@ECHO.:ERROR@ECHO.@ECHO An error has been detected.COLOR 4F@ECHO. GOTO :END:END@REM @REM Get finish time so we can evaluate total WinPE phase time.@REMCALL |time>x:\StopTime.txt@ECHO.FOR /f "tokens=5" %%A IN (x:\starttime.txt) DO ECHO Script Start Time is %%AFOR /f "tokens=5" %%A IN (x:\stoptime.txt) DO ECHO Script Stop Time is %%A@ECHO.
0 0
- WINPE镜像制作-main.cmd详解
- WINPE镜像制作-startnet.cmd详解
- 制作可自定义的winpe镜像
- 如何用 ISO 镜像制作 U 盘安装盘(通用方法、无需 WinPE)
- DOS/WinPE双启动U盘制作详解
- 利用WINPE恢复安装GHOST镜像文件
- 如何修改WinPE Boot的.wim镜像文件
- winpe iso镜像下载(exe转iso获取)
- WinPE制作语法
- 制作U盘版WinPE
- 制作WinPE基本知识
- 制作WinPE启动光盘教程
- 制作最新版WinPE 5.1
- winbuilder 制作winpe
- 3.3、Dcoker-1.12 Dockerfile,镜像制作详解以及使用说明
- 制作iso镜像
- 制作文件系统镜像
- 制作initramfs镜像
- 组合模式
- C++与Java比较
- Masonry布局的UIView动画
- Boost coroutine 协程
- 选择最好的
- WINPE镜像制作-main.cmd详解
- 一天一个设计模式---桥接模式
- OpenGL 记录 -- 关于“混合”渲染
- c# 用代码来设置程序的PrivatePath
- 380. Insert Delete GetRandom O(1)
- sql server数据类型转换
- 一个2年安卓开发者的一些忠告
- A*学习笔记 && POJ 2449
- 关于开发的一点感想