-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller_temp.bat
More file actions
139 lines (121 loc) · 5.75 KB
/
installer_temp.bat
File metadata and controls
139 lines (121 loc) · 5.75 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
@echo off
chcp 65001 >nul
echo ========================================
echo Windows Update管理工具 - 安装程序
echo ========================================
echo.
REM 检查管理员权限
net session >nul 2>&1
if %errorLevel% neq 0 (
echo ❌ 此程序需要管理员权限才能安装
echo 请右键点击安装程序,选择"以管理员身份运行"
pause
exit /b 1
)
REM 检查系统版本
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
if "%VERSION%" lss "10.0" (
echo ❌ 此程序需要Windows 10或更高版本
echo 当前系统版本不受支持
pause
exit /b 1
)
echo ✅ 权限和系统检查通过
echo.
REM 获取系统盘符
for /f "tokens=2 delims==" %%a in ('wmic os get SystemDrive /value') do set SYSTEMDRIVE=%%a
set "INSTALL_DIR=%SYSTEMDRIVE%\Program Files\WindowsUpdateManager"
echo 安装目录:%INSTALL_DIR%
echo.
REM 检查是否已安装
if exist "%INSTALL_DIR%\WindowsUpdateManager.exe" (
echo 检测到已安装的版本
set /p "CHOICE=是否要覆盖安装?(Y/N): "
if /i "%CHOICE%" neq "Y" (
echo 安装已取消
pause
exit /b 0
)
echo 正在停止现有程序...
taskkill /f /im WindowsUpdateManager.exe >nul 2>&1
)
echo 正在创建安装目录...
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
echo 正在解压程序文件...
echo 这可能需要几分钟时间,请耐心等待...
REM 解压文件到安装目录
xcopy "%~dp0WindowsUpdateManager_Portable\*" "%INSTALL_DIR%\" /E /I /H /Y >nul
if not exist "%INSTALL_DIR%\WindowsUpdateManager.exe" (
echo ❌ 安装失败,程序文件未正确复制
pause
exit /b 1
)
echo ✅ 程序文件安装完成
REM 创建桌面快捷方式
set /p "CREATE_DESKTOP=是否创建桌面快捷方式?(Y/N): "
if /i "%CREATE_DESKTOP%" equ "Y" (
echo 正在创建桌面快捷方式...
powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%USERPROFILE%\Desktop\Windows Update管理工具.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\WindowsUpdateManager.exe'; $Shortcut.Save()"
)
REM 创建开始菜单快捷方式
set /p "CREATE_STARTMENU=是否创建开始菜单快捷方式?(Y/N): "
if /i "%CREATE_STARTMENU%" equ "Y" (
echo 正在创建开始菜单快捷方式...
if not exist "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows Update管理工具" mkdir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows Update管理工具"
powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows Update管理工具\Windows Update管理工具.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\WindowsUpdateManager.exe'; $Shortcut.Save()"
powershell -Command "$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut('%APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows Update管理工具\使用说明.lnk'); $Shortcut.TargetPath = '%INSTALL_DIR%\USER_GUIDE.md'; $Shortcut.Save()"
)
REM 设置开机自启动
set /p "CREATE_AUTOSTART=是否设置开机自启动?(Y/N): "
if /i "%CREATE_AUTOSTART%" equ "Y" (
echo 正在设置开机自启动...
schtasks /create /tn "WindowsUpdateManager" /tr "%INSTALL_DIR%\WindowsUpdateManager.exe" /sc onlogon /ru SYSTEM /f >nul 2>&1
if %errorLevel% equ 0 (
echo ✅ 开机自启动设置成功
) else (
echo ⚠️ 开机自启动设置失败,可在程序中手动设置
)
)
REM 添加到程序列表
echo 正在注册程序信息...
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WindowsUpdateManager" /v "DisplayName" /t REG_SZ /d "Windows Update管理工具" /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WindowsUpdateManager" /v "DisplayVersion" /t REG_SZ /d "1.0.0" /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WindowsUpdateManager" /v "Publisher" /t REG_SZ /d "Windows Update Manager Team" /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WindowsUpdateManager" /v "InstallLocation" /t REG_SZ /d "%INSTALL_DIR%" /f >nul
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WindowsUpdateManager" /v "UninstallString" /t REG_SZ /d "%INSTALL_DIR%\uninstall.bat" /f >nul
REM 创建卸载脚本
echo @echo off > "%INSTALL_DIR%\uninstall.bat"
echo chcp 65001 ^>nul ^
echo echo 正在卸载Windows Update管理工具... ^
echo taskkill /f /im WindowsUpdateManager.exe ^>nul 2^>^&1 ^
echo schtasks /delete /tn "WindowsUpdateManager" /f ^>nul 2^>^&1 ^
echo del "%%USERPROFILE%%\Desktop\Windows Update管理工具.lnk" ^>nul 2^>^&1 ^
echo rmdir /s /q "%%APPDATA%%\Microsoft\Windows\Start Menu\Programs\Windows Update管理工具" ^>nul 2^>^&1 ^
echo reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\WindowsUpdateManager" /f ^>nul 2^>^&1 ^
echo rmdir /s /q "%INSTALL_DIR%" ^
echo echo 卸载完成 ^
echo pause ^
echo.
echo ========================================
echo 🎉 安装完成!
echo ========================================
echo.
echo 安装位置:%INSTALL_DIR%
echo.
echo 🚀 启动程序:
echo 双击桌面快捷方式或从开始菜单启动
echo 或直接运行:%INSTALL_DIR%\WindowsUpdateManager.exe
echo.
echo 📚 使用说明:
echo 查看:%INSTALL_DIR%\USER_GUIDE.md
echo.
echo 🗑️ 卸载程序:
echo 运行:%INSTALL_DIR%\uninstall.bat
echo 或通过"程序和功能"卸载
echo.
set /p "RUN_NOW=是否立即运行程序?(Y/N): "
if /i "%RUN_NOW%" equ "Y" (
start "" "%INSTALL_DIR%\WindowsUpdateManager.exe"
)
echo 感谢使用Windows Update管理工具!
pause