使用条件:须挂载ISO到本地Y盘
挂载方法:
1、PXE启动使用HTTPDISK挂载
2、使用局域网共享挂载ISO
3、存储设备放置ISO
日常维护之用,配合自动应答文件更省事!仅供参考!
[ol]@echo off
color 0a
mode con: cols=50 lines=40
title Windows系统全自动化安装器 By:as8686886
REM 判断ISO内是否有install.wim
IF NOT EXIST Y:\sources\install.wim (goto NoInsWIM)
REM 判断当前运行环境:WinPE执行、非PE拒绝执行
@reg query HKLM\SYSTEM\CurrentControlSet\Control |find "WinPE">NUL&&goto WinPE||goto NoWinPE
:WinPE
REM 判断启动模式BIOS或者UEFI
@reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType |find "0x1" >NUL&& set OSmode=BIOS || set OSmode=UEFI
if "%OSMode%"=="BIOS" goto BIOS
if "%OSMode%"=="UEFI" goto UEFI
REM goto NoWinPe
:BIOS
set BootDrv=C:
setlocal enabledelayedexpansion
(
echo select disk 0
echo clean
echo convert mbr
echo create partition primary
echo active
echo format fs=ntfs label="OS" quick
echo assign letter C
)>>%~dp0DISKPART.TXT
goto FDISK
:UEFI
set BootDrv=Z:
setlocal enabledelayedexpansion
(
echo select disk 0
echo clean
echo convert GPT
echo create partition efi size=500
echo format fs=fat32 label="ESP" quick
echo assign letter z
echo create partition primary
echo format fs=ntfs label="OS" quick
echo assign letter C
)>>%~dp0DISKPART.TXT
goto FDISK
:FDISK
echo.&echo 正在对磁盘进行分区……
diskpart /s DISKPART.TXT>NUL
cls
goto InstallOS
:InstallOS
set ISOPath=Y:\sources
echo 本ISO包含以下系统镜像:
dism /Get-WimInfo /WimFile:%ISOPath%\install.wim
set /P NUM=请输入要安装的系统索引号:[/ol]复制代码