mirror of
https://github.com/bin456789/reinstall.git
synced 2026-05-21 05:27:41 +08:00
Compare commits
3 Commits
7a02021d5d
...
f2bc04d90f
| Author | SHA1 | Date | |
|---|---|---|---|
| f2bc04d90f | |||
| e1fdbb18fa | |||
| 8fd50b7527 |
@ -331,7 +331,7 @@ bash reinstall.sh netboot.xyz
|
||||
- If remote login fails, try using the username `.\administrator`.
|
||||
- The machine with a static IP will automatically configure the IP. It may take a few minutes to take effect on the first boot.
|
||||
- Supports ISO images in any language.
|
||||
- Supports bypassing Windows 11 hardware requirements.
|
||||
- Automatically bypassing Windows 11 hardware requirements.
|
||||
|
||||
#### Supported Systems
|
||||
|
||||
@ -582,12 +582,14 @@ bash reinstall.sh reset
|
||||
|
||||
According to the Law of Bug Conservation, fixing old bugs often introduces new ones.
|
||||
|
||||
If a new bug occurs, try using an older version to see if it works.
|
||||
If a bug occurs, try using an older version to see if it works.
|
||||
|
||||
Go to <https://github.com/bin456789/reinstall/commits/main> and find the old version’s `commit_id` on the right side.
|
||||
|
||||
Replace `xxxxxxxx` in the script below with the `commit_id` of an older version and run the script.
|
||||
|
||||
```bash
|
||||
commit_id=xxxxxxx
|
||||
commit_id=xxxxxxxx
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
|
||||
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
|
||||
bash reinstall.sh ...
|
||||
@ -598,6 +600,7 @@ bash reinstall.sh ...
|
||||
1. Fork this repository.
|
||||
2. Modify the `confhome` and `confhome_cn` at the beginning of `reinstall.sh` and `reinstall.bat`.
|
||||
3. Make changes to the other code.
|
||||
4. Download and run your `reinstall.sh` or `reinstall.bat`."
|
||||
|
||||
## Thanks
|
||||
|
||||
|
||||
@ -331,7 +331,7 @@ bash reinstall.sh netboot.xyz
|
||||
- 如果远程登录失败,可以尝试使用用户名 `.\administrator`
|
||||
- 静态机器会自动配置好 IP,可能首次开机几分钟后才生效
|
||||
- 支持任意语言的 ISO
|
||||
- 支持绕过 Windows 11 硬件限制
|
||||
- 自动绕过 Windows 11 硬件限制
|
||||
|
||||
#### 支持的系统
|
||||
|
||||
@ -582,12 +582,14 @@ bash reinstall.sh reset
|
||||
|
||||
根据 Bug 守恒定律,修复旧 Bug 的同时会引入新的 Bug
|
||||
|
||||
如果遇到新的 Bug,可以试下旧版本是否正常
|
||||
如果脚本出现问题,可以试下旧版本是否正常
|
||||
|
||||
从 <https://github.com/bin456789/reinstall/commits/main> 右侧找到旧版本的 `commit_id`
|
||||
|
||||
将下面脚本的 `xxxxxxxx` 替换成旧版本的 `commit_id` 并运行脚本
|
||||
|
||||
```bash
|
||||
commit_id=xxxxxxx
|
||||
commit_id=xxxxxxxx
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/$commit_id/reinstall.sh || wget -O ${_##*/} $_
|
||||
sed -i "/^confhome.*main$/s/main/$commit_id/" reinstall.sh
|
||||
bash reinstall.sh ...
|
||||
@ -598,6 +600,7 @@ bash reinstall.sh ...
|
||||
1. Fork 本仓库
|
||||
2. 修改 `reinstall.sh` 和 `reinstall.bat` 开头的 `confhome` 和 `confhome_cn`
|
||||
3. 修改其它代码
|
||||
4. 下载并运行你的 `reinstall.sh` 或 `reinstall.bat`
|
||||
|
||||
## 感谢
|
||||
|
||||
|
||||
@ -702,12 +702,6 @@ is_virt() {
|
||||
$_is_virt
|
||||
}
|
||||
|
||||
is_absolute_path() {
|
||||
# 检查路径是否以/开头
|
||||
# 注意语法和 ash 不同
|
||||
[[ "$1" = /* ]]
|
||||
}
|
||||
|
||||
is_cpu_supports_x86_64_v3() {
|
||||
# 用 ld.so/cpuid/coreinfo.exe 更准确
|
||||
# centos 7 /usr/lib64/ld-linux-x86-64.so.2 没有 --help
|
||||
@ -3229,7 +3223,7 @@ build_cmdline() {
|
||||
|
||||
# 脚本可能多次运行,先清理之前的残留
|
||||
mkdir_clear() {
|
||||
dir=$1
|
||||
local dir=$1
|
||||
|
||||
if [ -z "$dir" ] || [ "$dir" = / ]; then
|
||||
return
|
||||
@ -3892,6 +3886,7 @@ This script is outdated, please download reinstall.sh again.
|
||||
|
||||
if [ "$hold" = 0 ]; then
|
||||
info 'hold 0'
|
||||
echo "Edit $tmp if needed."
|
||||
read -r -p 'Press Enter to continue...'
|
||||
fi
|
||||
|
||||
|
||||
21
trans.sh
21
trans.sh
@ -5738,10 +5738,15 @@ get_filesize_mb() {
|
||||
du -m "$1" | awk '{print $1}'
|
||||
}
|
||||
|
||||
is_absolute_path() {
|
||||
# 检查路径是否以/开头
|
||||
# 注意语法和 bash 不同
|
||||
[[ "$1" = "/*" ]]
|
||||
mkdir_clear() {
|
||||
local dir=$1
|
||||
|
||||
if [ -z "$dir" ] || [ "$dir" = / ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
rm -rf "$dir"
|
||||
mkdir -p "$dir"
|
||||
}
|
||||
|
||||
# 注意使用方法是 list=$(list_add "$list" "$item_to_add")
|
||||
@ -6014,7 +6019,7 @@ install_windows() {
|
||||
# 检测 sac 和 nvme
|
||||
{
|
||||
find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false
|
||||
find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false
|
||||
find_file_ignore_case /wim/Windows/System32/drivers/stornvme.sys && has_stornvme=true || has_stornvme=false
|
||||
} >/dev/null 2>&1
|
||||
|
||||
# 检测是否支持 sha256 签名的驱动
|
||||
@ -6234,8 +6239,9 @@ install_windows() {
|
||||
add_drivers() {
|
||||
info "Add drivers"
|
||||
|
||||
# 驱动下载临时文件夹
|
||||
drv=/os/drivers
|
||||
mkdir -p "$drv" # 驱动下载临时文件夹
|
||||
mkdir_clear "$drv"
|
||||
|
||||
# 这里有坑
|
||||
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
|
||||
@ -6743,8 +6749,7 @@ EOF
|
||||
cp_drivers $drv/virtio -ipath "*/$virtio_sys/$arch/*" "$@"
|
||||
fi
|
||||
else
|
||||
# coreutils 的 cp mv rm 才有 -v 参数
|
||||
apk add 7zip file coreutils
|
||||
apk add 7zip file
|
||||
download $baseurl/$dir/virtio-win-gt-$arch_xdd.msi $drv/virtio.msi
|
||||
match="FILE_*_${virtio_sys}_${arch}*"
|
||||
7z x $drv/virtio.msi -o$drv/virtio -i!$match -y -bb1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/ash
|
||||
# shellcheck shell=dash
|
||||
# shellcheck disable=SC3001,SC3003,SC3010
|
||||
# shellcheck disable=SC3001,SC3003,SC3010,SC3015
|
||||
# reinstall.sh / trans.sh 共用此文件
|
||||
|
||||
# grep 无法处理 UTF-16LE 编码的 inf,有以下几种解决方法
|
||||
@ -239,6 +239,27 @@ list_files_from_inf() {
|
||||
done < <(echo "$inf_txts")
|
||||
}
|
||||
|
||||
is_x_starts_with_y() {
|
||||
[[ "$1" =~ ^"$2" ]]
|
||||
}
|
||||
|
||||
is_x_ends_with_y() {
|
||||
[[ "$1" =~ "$2"$ ]]
|
||||
}
|
||||
|
||||
is_absolute_path() {
|
||||
# 检查路径是否以/开头
|
||||
|
||||
# alpine ash 可用
|
||||
# [[ "$1" = "/*" ]]
|
||||
|
||||
# bash 可用
|
||||
# [[ "$1" = /* ]]
|
||||
|
||||
# 都可用
|
||||
is_x_starts_with_y "$1" /
|
||||
}
|
||||
|
||||
# windows 安装驱动时,只会安装相同架构的驱动文件到系统,即使 inf 里有列出其它架构的驱动
|
||||
# 因此 DISM 导出驱动时,也就没有包含其它架构的驱动文件
|
||||
|
||||
@ -284,7 +305,11 @@ get_path_in_correct_case() {
|
||||
output="$output$part/"
|
||||
else
|
||||
# 最后 part
|
||||
output="$output$part"
|
||||
if is_x_ends_with_y "$path" /; then
|
||||
output="$output$part/"
|
||||
else
|
||||
output="$output$part"
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
@ -49,29 +49,22 @@ if exist X:\custom_drivers\ (
|
||||
rem 等待加载分区
|
||||
call :sleep 5000
|
||||
echo rescan | diskpart
|
||||
|
||||
rem 判断 efi 还是 bios
|
||||
rem 或者用 https://learn.microsoft.com/windows-hardware/manufacture/desktop/boot-to-uefi-mode-or-legacy-bios-mode
|
||||
rem pe 下没有 mountvol
|
||||
echo list vol | diskpart | find "efi" && (
|
||||
set BootType=efi
|
||||
) || (
|
||||
set BootType=bios
|
||||
)
|
||||
call :sleep 5000
|
||||
|
||||
rem 获取 ProductType
|
||||
rem for /f "tokens=3" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions" /v ProductType') do (
|
||||
rem set "ProductType=%%a"
|
||||
rem )
|
||||
|
||||
rem 获取 BuildNumber
|
||||
for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (
|
||||
set "BuildNumber=%%a"
|
||||
rem 获取 installer 卷 id
|
||||
for /f "tokens=2" %%a in ('echo list vol ^| diskpart ^| find " installer "') do (
|
||||
set "VolIndex=%%a"
|
||||
)
|
||||
|
||||
rem 获取 installer 卷 id
|
||||
for /f "tokens=2" %%a in ('echo list vol ^| diskpart ^| find "installer"') do (
|
||||
set "VolIndex=%%a"
|
||||
rem 及时退出
|
||||
if "%VolIndex%"=="" (
|
||||
echo "Error: Cannot find installer partition." >&2
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
rem 将 installer 分区设为 Y 盘
|
||||
@ -93,6 +86,15 @@ for /f "tokens=3" %%a in (X:\disk.txt) do (
|
||||
)
|
||||
del X:\disk.txt
|
||||
|
||||
rem 判断 efi 还是 bios
|
||||
rem 或者用 https://learn.microsoft.com/windows-hardware/manufacture/desktop/boot-to-uefi-mode-or-legacy-bios-mode
|
||||
rem pe 下没有 mountvol
|
||||
echo list vol | diskpart | find " efi " && (
|
||||
set BootType=efi
|
||||
) || (
|
||||
set BootType=bios
|
||||
)
|
||||
|
||||
rem 这个变量会被 trans.sh 修改
|
||||
set is4kn=0
|
||||
if "%is4kn%"=="1" (
|
||||
@ -105,6 +107,7 @@ rem 重新分区/格式化
|
||||
(if "%BootType%"=="efi" (
|
||||
echo select disk %DiskIndex%
|
||||
|
||||
rem del
|
||||
echo select part 1
|
||||
echo delete part override
|
||||
echo select part 2
|
||||
@ -112,23 +115,31 @@ rem 重新分区/格式化
|
||||
echo select part 3
|
||||
echo delete part override
|
||||
|
||||
rem 1
|
||||
echo create part efi size=%EFISize%
|
||||
echo format fs=fat32 quick
|
||||
|
||||
rem 2
|
||||
echo create part msr size=16
|
||||
|
||||
rem 3
|
||||
echo create part primary
|
||||
echo format fs=ntfs quick
|
||||
rem echo assign letter=Z
|
||||
|
||||
) else (
|
||||
echo select disk %DiskIndex%
|
||||
|
||||
rem del
|
||||
echo select part 1
|
||||
rem echo delete part override
|
||||
rem echo create part primary
|
||||
echo delete part override
|
||||
|
||||
rem 1
|
||||
echo create part primary
|
||||
echo format fs=ntfs quick
|
||||
echo active
|
||||
rem echo assign letter=Z
|
||||
|
||||
)) > X:\diskpart.txt
|
||||
|
||||
rem 使用 diskpart /s ,出错不会执行剩下的 diskpart 命令
|
||||
@ -140,6 +151,11 @@ rem X boot.wim (ram)
|
||||
rem Y installer
|
||||
rem Z os
|
||||
|
||||
rem 获取 BuildNumber
|
||||
for /f "tokens=3" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (
|
||||
set "BuildNumber=%%a"
|
||||
)
|
||||
|
||||
rem 旧版安装程序会自动在C盘设置虚拟内存,新版安装程序(24h2)不会
|
||||
rem 如果不创建虚拟内存,1g 内存的机器安装时会报错/杀进程
|
||||
if %BuildNumber% GEQ 26040 (
|
||||
@ -180,11 +196,25 @@ rem 运行 ramdisk X:\setup.exe 的话
|
||||
rem vista 会找不到安装源
|
||||
rem server 23h2 会无法运行
|
||||
rem 使用 /installfrom 可以解决?
|
||||
if "%ForceOldSetup%"=="1" (
|
||||
|
||||
rem 有的精简版 iso install.wim 根目录没有 setup.exe
|
||||
rem https://github.com/bin456789/reinstall/issues/578
|
||||
|
||||
if "%ForceOldSetup%"=="1" if exist Y:\sources\setup.exe (
|
||||
set setup=Y:\sources\setup.exe
|
||||
) else (
|
||||
set setup=Y:\setup.exe
|
||||
goto :SetupExeFound
|
||||
)
|
||||
if exist Y:\setup.exe (
|
||||
set setup=Y:\setup.exe
|
||||
) else if exist Y:\sources\setup.exe (
|
||||
set setup=Y:\sources\setup.exe
|
||||
) else if exist X:\setup.exe (
|
||||
set setup=X:\setup.exe
|
||||
) else (
|
||||
echo "Error: setup.exe not found." >&2
|
||||
exit /b 1
|
||||
)
|
||||
:SetupExeFound
|
||||
|
||||
if "%EnableUnattended%"=="1" (
|
||||
set Unattended=/unattend:X:\windows.xml
|
||||
@ -246,6 +276,12 @@ exit /b
|
||||
rem 不要查找 Class=SCSIAdapter 因为有些驱动等号两边有空格
|
||||
find /i "SCSIAdapter" "%~1" >nul
|
||||
if not errorlevel 1 (
|
||||
rem 有 N 种方法安装驱动
|
||||
rem 1. dism /online /add-driver /driver:"%~1" # PE 不支持 /online 添加驱动
|
||||
rem 2. pnputil -i -a "%~1"
|
||||
rem 3. devcon
|
||||
rem 4. dpinst
|
||||
rem 5. drvload 官方推荐 https://learn.microsoft.com/windows-hardware/manufacture/desktop/drvload-command-line-options
|
||||
drvload "%~1"
|
||||
)
|
||||
exit /b
|
||||
|
||||
@ -155,7 +155,9 @@
|
||||
</UserAccounts>
|
||||
<OOBE>
|
||||
<HideEULAPage>true</HideEULAPage>
|
||||
<ProtectYourPC>3</ProtectYourPC>
|
||||
<!-- 文档说请勿使用 SkipMachineOOBE 设置自动执行 OOBE -->
|
||||
<!-- 但是 Azure 的系统镜像也是用了 SkipMachineOOBE -->
|
||||
<!-- https://learn.microsoft.com/windows-hardware/customize/desktop/automate-oobe -->
|
||||
<SkipMachineOOBE>true</SkipMachineOOBE>
|
||||
<SkipUserOOBE>true</SkipUserOOBE>
|
||||
</OOBE>
|
||||
|
||||
Reference in New Issue
Block a user