不吐不快-github push失败(批处理if语句中弹窗)

不吐不快-github push失败(批处理if语句中弹窗)

五月 15, 2025 阅读量

前段时间,github的工程无法push上去了,以前虽然github.com经常不能访问,但是push不上去貌似是第一次,而且持续了一周,中间只成功过一次提交

应对

因为经常提交失败就写了一段批处理脚本来自动提交

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
@echo off
setlocal enabledelayedexpansion

:: ============== 配置区 ==============
set "TARGET_DIR=C:\Users\xuchl\Desktop\xuchlei.github.io" :: 仓库路径
set "RETRY_DELAY=60" :: 重试间隔秒数
:: ===================================

:: 验证目录是否存在
if not exist "%TARGET_DIR%" (
echo ? 错误:目录不存在 "%TARGET_DIR%"
pause
exit /b 1
)

:: 进入目标仓库目录
cd /d "%TARGET_DIR%"

set ATTEMPT=0
:retry_push
set /a ATTEMPT+=1
echo [尝试 !ATTEMPT! 次] 正在提交到远程仓库...

git push

if %errorlevel% equ 0 (
echo Git 提交成功!
mshta vbscript:"<script language=""vbscript"">msgbox(""Git Push 成功""):self.close </script></html>"
) else (
echo 提交失败,%RETRY_DELAY%秒后重试...
timeout /t %RETRY_DELAY% /nobreak >nul
goto retry_push
)

然而并没有什么卵用,一整天都无法成功

其中弹窗遇到一些问题,发现只要弹窗语句中经常报缺少’)’的错误。

批处理弹窗

一些弹窗语句:

1
2
3
4
5
6
7
8
9
10
11
12
13
mshta vbscript:msgbox("Git Push 成功",6,"提示")(window.close)
# 单行if无()可以用
if 1==1 mshta vbscript:msgbox("Git Push 成功",6,"提示")(window.close)

mshta vbscript:execute("msgbox ""Git Push 成功"":window.close")

mshta vbscript:CreateObject("Wscript.Shell").popup("Git Push 成功",7,"提示",64)(window.close)

mshta javascript:window.execScript("msgBox('Git Push 成功'):window.close","vbs")

mshta vbscript:"<script language=""vbscript"">msgbox(""Git Push 成功""):self.close </script></html>"

msg %username% /time 100 "Git Push 成功"

可以在if () 中能使用的弹窗:

1
2
3
4
if 1==1 (
mshta vbscript:"<script language=""vbscript"">msgbox(""Git Push 成功""):self.close </script></html>"
msg %username% /time 100 "Git Push 成功"
)