mirror of
https://github.com/bin456789/reinstall.git
synced 2025-12-10 07:28:56 +08:00
windows: 在 pe 下设置主硬盘 id
This commit is contained in:
41
windows-setup.bat
Normal file
41
windows-setup.bat
Normal file
@ -0,0 +1,41 @@
|
||||
@echo off
|
||||
|
||||
:: 安装 SCSI 驱动
|
||||
for %%F in ("X:\drivers\*.inf") do (
|
||||
find "Class=SCSIAdapter" "%%~F" >nul
|
||||
if not errorlevel 1 (
|
||||
drvload "%%~F"
|
||||
)
|
||||
)
|
||||
|
||||
:: 等待加载分区
|
||||
:: 没有 timeout 命令
|
||||
:: 没有加载网卡驱动,无法用 ping 来等待
|
||||
echo wscript.sleep(5000) > sleep.vbs
|
||||
cscript //nologo sleep.vbs
|
||||
|
||||
:: 获取主硬盘 id
|
||||
for /F "tokens=2 delims==" %%A in ('wmic logicaldisk where "VolumeName='installer'" assoc:value /resultclass:Win32_DiskPartition ^| find "DiskIndex"') do (
|
||||
set "DiskIndex=%%A"
|
||||
)
|
||||
|
||||
:: 设置 Autounattend.xml 的主硬盘 id
|
||||
set "file=X:\Autounattend.xml"
|
||||
set "tempFile=X:\tmp.xml"
|
||||
|
||||
set "search=%%disk_id%%"
|
||||
set "replace=%DiskIndex%"
|
||||
|
||||
(for /f "delims=" %%i in (%file%) do (
|
||||
set "line=%%i"
|
||||
|
||||
setlocal EnableDelayedExpansion
|
||||
echo !line:%search%=%replace%!
|
||||
endlocal
|
||||
|
||||
)) > %tempFile%
|
||||
move /y %tempFile% %file%
|
||||
|
||||
:: 执行 setup.exe
|
||||
ren X:\setup.exe.disabled setup.exe
|
||||
X:\setup.exe
|
||||
Reference in New Issue
Block a user