From 35221e56b7fbab41fd4af11209a42a35b839bab6 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Fri, 6 Sep 2024 23:00:34 +0800 Subject: [PATCH] =?UTF-8?q?windows:=20=E5=85=81=E8=AE=B8=2010=20=E7=A7=92?= =?UTF-8?q?=E5=86=85=E5=8F=96=E6=B6=88=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 3 +++ windows-setup.bat | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/trans.sh b/trans.sh index a351581..dc1411b 100644 --- a/trans.sh +++ b/trans.sh @@ -3940,6 +3940,9 @@ install_windows() { unix2dos /wim/autounattend.xml cat /wim/autounattend.xml + # 避免无参数运行 setup.exe 时自动安装 + mv /wim/autounattend.xml /wim/windows.xml + # 复制安装脚本 # https://slightlyovercomplicated.com/2016/11/07/windows-pe-startup-sequence-explained/ mv /wim/setup.exe /wim/setup.exe.disabled diff --git a/windows-setup.bat b/windows-setup.bat index 75df57c..c3698f0 100644 --- a/windows-setup.bat +++ b/windows-setup.bat @@ -1,6 +1,14 @@ @echo off mode con cp select=437 >nul +rem 还原 setup.exe +rename X:\setup.exe.disabled setup.exe + +rem 等待 10 秒才自动安装 +echo Press Ctrl+C within 10 seconds to cancel the automatic installation. +call :sleep 10000 +cls + rem win7 find 命令在 65001 代码页下有问题,仅限 win 7 rem findstr 就正常,但安装程序又没有 findstr rem echo a | find "a" @@ -89,8 +97,8 @@ rem 盘符 rem X boot.wim (ram) rem Y installer -rem 设置 autounattend.xml 的主硬盘 id -set "file=X:\autounattend.xml" +rem 设置应答文件的主硬盘 id +set "file=X:\windows.xml" set "tempFile=X:\tmp.xml" set "search=%%disk_id%%" @@ -106,7 +114,6 @@ set "replace=%DiskIndex%" )) > %tempFile% move /y %tempFile% %file% -rename X:\setup.exe.disabled setup.exe rem https://github.com/pbatard/rufus/issues/1990 for %%a in (RAM TPM SecureBoot) do ( @@ -116,11 +123,16 @@ for %%a in (RAM TPM SecureBoot) do ( rem 设置 set EnableEMS=0 set ForceOldSetup=1 +set EnableUnattended=1 if %EnableEMS% EQU 1 ( set EMS=/EMSPort:COM1 /EMSBaudRate:115200 ) +if %EnableUnattended% EQU 1 ( + set Unattended=/unattend:X:\windows.xml +) + rem 运行 ramdisk X:\setup.exe 的话 rem vista 会找不到安装源 rem server 23h2 会无法运行 @@ -142,12 +154,13 @@ if %ForceOldSetup% EQU 1 ( ) ) -%setup% %ResizeRecoveryPartition% %EMS% +%setup% %ResizeRecoveryPartition% %EMS% %Unattended% exit /b :sleep -rem 没有 timeout 命令 rem 没有加载网卡驱动,无法用 ping 来等待 +rem 没有 timeout 命令 +rem timeout /t 10 /nobreak echo wscript.sleep(%~1) > X:\sleep.vbs cscript //nologo X:\sleep.vbs del X:\sleep.vbs