core: 批处理脚本改用 rem 注释

This commit is contained in:
bin456789
2024-01-28 00:00:21 +08:00
parent 76738362f1
commit 85b1b1bd58
3 changed files with 60 additions and 59 deletions

View File

@ -3,33 +3,36 @@ setlocal EnableDelayedExpansion
set confhome=https://raw.githubusercontent.com/bin456789/reinstall/main
set github_proxy=raw.fgit.cf
:: Windows 7 SP1 winhttp 默认不支持 tls 1.2
:: https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392
:: 有些系统根证书没更新
:: 所以不要用https
:: 进入脚本目录
rem 不要用 :: 注释
rem 否则可能会出现 系统找不到指定的驱动器
rem Windows 7 SP1 winhttp 默认不支持 tls 1.2
rem https://support.microsoft.com/en-us/topic/update-to-enable-tls-1-1-and-tls-1-2-as-default-secure-protocols-in-winhttp-in-windows-c4bd73d2-31d7-761e-0178-11268bb10392
rem 有些系统根证书没更新
rem 所以不要用https
rem 进入脚本目录
cd /d %~dp0
:: 检查是否有管理员权限
rem 检查是否有管理员权限
openfiles 1>nul 2>&1
if not !errorlevel! == 0 (
echo Please run as administrator^^!
exit /b
)
:: 有时 %tmp% 带会话 id且文件夹不存在
:: https://learn.microsoft.com/troubleshoot/windows-server/shell-experience/temp-folder-with-logon-session-id-deleted
rem 有时 %tmp% 带会话 id且文件夹不存在
rem https://learn.microsoft.com/troubleshoot/windows-server/shell-experience/temp-folder-with-logon-session-id-deleted
if not exist %tmp% (
md %tmp%
)
:: 检查是否国内
rem 检查是否国内
if not exist %tmp%\geoip (
call :download http://www.cloudflare.com/cdn-cgi/trace %tmp%\geoip
)
findstr /c:"loc=CN" %tmp%\geoip >nul
if !errorlevel! == 0 (
:: mirrors.tuna.tsinghua.edu.cn 会强制跳转 https
rem mirrors.tuna.tsinghua.edu.cn 会强制跳转 https
set mirror=http://mirror.nju.edu.cn
if defined github_proxy (
@ -43,15 +46,13 @@ if !errorlevel! == 0 (
set mirror=http://mirrors.kernel.org
)
:: pkgs 改动了才重新运行 Cygwin 安装程序
rem pkgs 改动了才重新运行 Cygwin 安装程序
set pkgs="curl,cpio,p7zip,bind-utils,ipcalc"
set tags=%tmp%\cygwin-installed-!pkgs!
if not exist !tags! (
:: 检查32/64位
:: win10 arm 支持运行 x86 软件
:: win11 arm 支持运行 x86 和 x86_64 软件
:: wmic os get osarchitecture
rem win10 arm 支持运行 x86 软件
rem win11 arm 支持运行 x86 和 x86_64 软件
rem wmic os get osarchitecture
wmic ComputerSystem get SystemType | find "ARM" > nul
if not errorlevel 1 (
for /f "tokens=2 delims==" %%a in ('wmic os get BuildNumber /format:list ^| find "BuildNumber"') do set BuildNumber=%%a
@ -75,10 +76,10 @@ if not exist !tags! (
set dir=/sourceware/cygwin-archive/20221123
)
:: 下载 Cygwin
rem 下载 Cygwin
call :download http://www.cygwin.com/setup-!CygwinArch!.exe %tmp%\setup-cygwin.exe
:: 安装 Cygwin
rem 安装 Cygwin
set site=!mirror!!dir!
%tmp%\setup-cygwin.exe --allow-unsupported-windows ^
--quiet-mode ^
@ -90,25 +91,25 @@ if not exist !tags! (
&& type nul >!tags!
)
:: 下载 reinstall.sh
rem 下载 reinstall.sh
if not exist reinstall.sh (
call :download %confhome%/reinstall.sh %~dp0reinstall.sh
)
:: 为每个参数添加引号,使参数正确传递到 bash
rem 为每个参数添加引号,使参数正确传递到 bash
for %%a in (%*) do (
set "param=!param! "%%~a""
)
:: 在c盘根目录下执行 cygpath -ua . 会得到 /cygdrive/c因此末尾要有 /
rem 在c盘根目录下执行 cygpath -ua . 会得到 /cygdrive/c因此末尾要有 /
for /f %%a in ('%SystemDrive%\cygwin\bin\cygpath -ua ./') do set thisdir=%%a
:: 方法1
rem 方法1
%SystemDrive%\cygwin\bin\bash -l -c '%thisdir%reinstall.sh !param!'
:: 方法2
:: %SystemDrive%\cygwin\bin\bash reinstall.sh %*
:: 再在 reinstall.sh 里运行 source /etc/profile
rem 方法2
rem %SystemDrive%\cygwin\bin\bash reinstall.sh %*
rem 再在 reinstall.sh 里运行 source /etc/profile
exit /b !errorlevel!
@ -116,9 +117,9 @@ exit /b !errorlevel!
:download
:: bits 要求有 Content-Length 才能下载
:: https://learn.microsoft.com/en-us/windows/win32/bits/http-requirements-for-bits-downloads
:: certutil 会被 windows Defender 报毒
rem bits 要求有 Content-Length 才能下载
rem https://learn.microsoft.com/en-us/windows/win32/bits/http-requirements-for-bits-downloads
rem certutil 会被 windows Defender 报毒
echo Download: %~1 %~2
certutil -urlcache -f -split %~1 %~2
exit /b !errorlevel!