windows: 修复安装 win7 iso 时无法设置静态 IP

This commit is contained in:
bin456789 2023-11-02 23:53:15 +08:00
parent e67575c2a7
commit 1e681d29b8
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 20 additions and 11 deletions

View File

@ -922,12 +922,14 @@ EOF
} }
modify_windows() { modify_windows() {
os_dir=$1
# https://learn.microsoft.com/zh-cn/windows-hardware/manufacture/desktop/windows-setup-states # https://learn.microsoft.com/zh-cn/windows-hardware/manufacture/desktop/windows-setup-states
# https://learn.microsoft.com/zh-cn/troubleshoot/azure/virtual-machines/reset-local-password-without-agent # https://learn.microsoft.com/zh-cn/troubleshoot/azure/virtual-machines/reset-local-password-without-agent
# https://learn.microsoft.com/zh-cn/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup # https://learn.microsoft.com/zh-cn/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup
# 判断用 SetupComplete 还是组策略 # 判断用 SetupComplete 还是组策略
state_ini=/os/Windows/Setup/State/State.ini state_ini=$os_dir/Windows/Setup/State/State.ini
cat $state_ini cat $state_ini
if grep -q IMAGE_STATE_COMPLETE $state_ini; then if grep -q IMAGE_STATE_COMPLETE $state_ini; then
use_gpo=true use_gpo=true
@ -938,13 +940,13 @@ modify_windows() {
# 下载共同的子脚本 # 下载共同的子脚本
# 可能 unattend.xml 已经设置了ExtendOSPartition不过运行resize没副作用 # 可能 unattend.xml 已经设置了ExtendOSPartition不过运行resize没副作用
bats="windows-resize.bat windows-set-netconf.bat" bats="windows-resize.bat windows-set-netconf.bat"
download $confhome/windows-resize.bat /os/windows-resize.bat download $confhome/windows-resize.bat $os_dir/windows-resize.bat
create_win_set_netconf_script /os/windows-set-netconf.bat create_win_set_netconf_script $os_dir/windows-set-netconf.bat
if $use_gpo; then if $use_gpo; then
# 使用组策略 # 使用组策略
gpt_ini=/os/Windows/System32/GroupPolicy/gpt.ini gpt_ini=$os_dir/Windows/System32/GroupPolicy/gpt.ini
scripts_ini=/os/Windows/System32/GroupPolicy/Machine/Scripts/scripts.ini scripts_ini=$os_dir/Windows/System32/GroupPolicy/Machine/Scripts/scripts.ini
mkdir -p "$(dirname $scripts_ini)" mkdir -p "$(dirname $scripts_ini)"
# 备份 ini # 备份 ini
@ -989,10 +991,10 @@ EOF
unix2dos $scripts_ini unix2dos $scripts_ini
# windows-del-gpo.bat # windows-del-gpo.bat
download $confhome/windows-del-gpo.bat /os/windows-del-gpo.bat download $confhome/windows-del-gpo.bat $os_dir/windows-del-gpo.bat
else else
# 使用 SetupComplete # 使用 SetupComplete
setup_complete=/os/Windows/Setup/Scripts/SetupComplete.cmd setup_complete=$os_dir/Windows/Setup/Scripts/SetupComplete.cmd
mkdir -p "$(dirname $setup_complete)" mkdir -p "$(dirname $setup_complete)"
# 添加到 C:\Setup\Scripts\SetupComplete.cmd 最前面 # 添加到 C:\Setup\Scripts\SetupComplete.cmd 最前面
@ -1843,8 +1845,14 @@ EOF
# TODO: 由于esd文件无法修改要将resize.bat放到boot.wim # TODO: 由于esd文件无法修改要将resize.bat放到boot.wim
if [[ "$install_wim" = "*.wim" ]]; then if [[ "$install_wim" = "*.wim" ]]; then
wimmountrw $install_wim "$image_name" /wim/ wimmountrw $install_wim "$image_name" /wim/
download $confhome/windows-resize.bat /wim/windows-resize.bat if false; then
create_win_set_netconf_script /wim/windows-set-netconf.bat # 使用 Autounattend.xml
# win7 在此阶段找不到网卡
download $confhome/windows-resize.bat /wim/windows-resize.bat
create_win_set_netconf_script /wim/windows-set-netconf.bat
else
modify_windows /wim
fi
wimunmount --commit /wim/ wimunmount --commit /wim/
fi fi

View File

@ -98,14 +98,15 @@
<Order>4</Order> <Order>4</Order>
<Path>net user Administrator /active:yes</Path> <Path>net user Administrator /active:yes</Path>
</RunSynchronousCommand> </RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add"> <!-- win7 在此阶段找不到网卡 -->
<!-- <RunSynchronousCommand wcm:action="add">
<Order>5</Order> <Order>5</Order>
<Path>cmd /c "if exist %SystemDrive%\windows-resize.bat (call %SystemDrive%\windows-resize.bat)"</Path> <Path>cmd /c "if exist %SystemDrive%\windows-resize.bat (call %SystemDrive%\windows-resize.bat)"</Path>
</RunSynchronousCommand> </RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add"> <RunSynchronousCommand wcm:action="add">
<Order>6</Order> <Order>6</Order>
<Path>cmd /c "if exist %SystemDrive%\windows-set-netconf.bat (call %SystemDrive%\windows-set-netconf.bat)"</Path> <Path>cmd /c "if exist %SystemDrive%\windows-set-netconf.bat (call %SystemDrive%\windows-set-netconf.bat)"</Path>
</RunSynchronousCommand> </RunSynchronousCommand> -->
</RunSynchronous> </RunSynchronous>
</component> </component>
<component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="%arch%" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="%arch%" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">