-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-win_zhcn.bat
126 lines (104 loc) · 3.47 KB
/
install-win_zhcn.bat
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
chcp 65001
@echo off
setlocal enabledelayedexpansion
echo.
echo.
echo.
echo.
echo.
echo.
echo ------------------------------
echo 查找Discord安装路径
set discordPath="%LOCALAPPDATA%\Discord"
if exist !discordPath! (
echo Discord安装: !discordPath!
) else (
echo 未检测到Discord安装目录
pause
exit /b
)
set discordRoamingPath="%USERPROFILE%\AppData\Roaming\discord"
if exist !discordRoamingPath! (
echo Discord用户: !discordRoamingPath!
) else (
echo Discord缺少主要文件,请先完整启动一次Discord后再次运行
pause
exit /b
)
echo ------------------------------
echo 检测app.asar文件...
if not exist app.asar (
echo 当前目录下没有找到app.asar文件,开始从Github下载...
powershell -Command "Invoke-WebRequest -Uri 'https://github.com/XiaoXianHW/Discord-Skip-AutoUpdate/releases/download/AppAsar/app-win.asar' -OutFile 'app.asar'"
for %%I in (app.asar) do set fileSize=%%~zI
if not !fileSize!==6173488 (
echo app.asar不完整,需要自行重新下载。
pause
exit /b
)
)
echo app.asar已就绪
echo ------------------------------
echo 检查Discord进程...
tasklist | findstr /i "Discord.exe" >nul
if not errorlevel 1 (
echo 请关闭Discord进程后再运行本脚本
pause
exit /b
)
echo Discord未在运行
echo ------------------------------
echo 备份app.asar...
for /d %%a in ("!discordPath!\app-*") do (
set discordAppDir=%%a
break
)
if exist "!discordAppDir!\resources\app.asar" (
move /Y "!discordAppDir!\resources\app.asar" "!discordAppDir!\resources\app.asar.bak"
echo app.asar已被备份为app.asar.bak
) else (
echo 未找到app.asar,跳过备份步骤
)
echo ------------------------------
echo 更新Discord的app.asar...
if defined discordAppDir (
copy /Y app.asar "!discordAppDir!\resources\"
echo app.asar已替换至!discordAppDir!\resources\
) else (
echo 没有找到Discord的app-*目录
pause
exit /b
)
echo ------------------------------
echo 复制Modules到Discord用户路径...
for /f "tokens=2 delims=-" %%b in ("!discordAppDir!") do (
set "versionNumber=%%b"
)
set "sourceDir=!discordPath!\app-!versionNumber!\modules"
set "destDir=!discordRoamingPath!\!versionNumber!\modules"
for /d %%c in ("!sourceDir!\*") do (
for /d %%d in ("%%c\*") do (
echo 正在复制: %%d -> !destDir!\%%~nd
xcopy /E /I "%%d" "!destDir!\%%~nd\"
)
)
echo.
echo Modules复制完成
echo ------------------------------
echo 更新Discord开始菜单快捷方式...
set startMenuLink="%APPDATA%\Microsoft\Windows\Start Menu\Programs\Discord Inc\Discord.lnk"
if exist !startMenuLink! (
del !startMenuLink!
)
powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('!startMenuLink!'); $Shortcut.TargetPath = '!discordAppDir!\Discord.exe'; $Shortcut.Save()"
echo 更新Discord桌面快捷方式...
for /f "tokens=2*" %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do set desktopPath=%%b
set desktopLink="!desktopPath!\Discord.lnk"
if exist "!desktopLink!" (
del "!desktopLink!"
)
powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('!desktopLink!'); $Shortcut.TargetPath = '!discordAppDir!\Discord.exe'; $Shortcut.Save()"
echo Discord快捷方式已更新。
echo ------------------------------
echo Discord-Skip-AutoUpdate更新成功!
pause