前言 bat代码使用方法:
新建文本文档
把代码复制进去
另存为,编码格式改为ANSI,文件后缀改为.bat
编码格式不改为ANSI也可以,需要添加chcp 65001
这一行命令。
此命令设置当前命令行窗口的代码页为 UTF-8(代码页 65001),从而使得命令行能够正确显示和处理 UTF-8 编码的字符,避免字符乱码问题。
强制删除顽固目录 例如删除某个文件时出现文件正在使用,操作无法完成,因为文件在资源管理器中打开
,或者项目不在某文件夹中。
1 2 3 @echo off DEL /F /A /Q \\?\%1 RD /S /Q \\?\%1
新建文档将代码复制进去,改文档后缀为bat。将顽固文件拖入bat即可删除
设置txt、office背景护眼绿色 1 2 3 4 5 reg add "HKCU\Control Panel\Colors" \ /v Window \ /t REG_SZ \ /d "202 234 206" \ /f
恢复成默认的白色背景,把202 234 206
改成255 255 255
,然后重启电脑
1 2 3 4 5 6 7 8 @echo off start "" "C:\Program Files (x86)\Tencent\WeChat\WeChat.exe" /MultiInstance /config:"C:\WeChatData1" start "" "C:\Program Files (x86)\Tencent\WeChat\WeChat.exe" /MultiInstance /config:"C:\WeChatData2" start "" "C:\Program Files (x86)\Tencent\WeChat\WeChat.exe" /MultiInstance /config:"C:\WeChatData3"
把路径换成自己安装微信的路径,想多开几个就复制几行代码。上面代码可以多开3个微信
新建文本文档
快速获取当前文件夹内所有文件的名字,并把所有名字保存到当前文件夹的file_list.txt文件
1 2 @echo off dir /b > file_list.txt
批量重命名当前文件夹下的所有文件夹名称,新的文件夹名称按照阿拉伯数字从1开始依次命名
1 2 3 4 5 6 7 @echo off setlocal EnableDelayedExpansionset a=0 for /d %%i in (*) do ( set /A a+=1 ren "%%i " "!a! " )
命令行批量重命名 批量更改文件名的一部分 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 @echo off set /p "str1=请输入要替换的文件(文件夹)名字符串(可替换空格):" set /p "str2=请输入替换后的文件(文件夹)名字符串(去除则直接回车):" echo .echo 正在修改文件(夹)名中,请稍候……for /f "delims=" %%a in ('dir /s /b ^| sort /+65535' ) do ( if "%%~nxa" neq "%~nx0" ( set "file=%%a" set "name=%%~na" set "extension=%%~xa" setlocal enabledelayedexpansion call set "name=%%name:%str1%=%str2%%%" ren "!file!" "!name!!extension!" 2>nul endlocal ) ) exit
截取文件名 以下全部操作都要在命令行中执行,首先在命令行中定位到需要命名的文件夹再执行。所有windows操作系统都支持!
把文件名改成原文件名的前几位
87654321.txt
更改为:8765.txt
注意: 在命令中,问号(?)是一个通配符字符,表示可以匹配任意单个 字符。在文件名中使用问号可以代替一个字符或一个数字。所以想要截取前几个字符就需要使用相同个数的问号(?)来占位。
批量加后缀 比如一堆文件,需要设置统一的后缀,常见于文件加版权。
321.txt
更改为:321_blogh.tjyll.com.txt
1 ren *.txt ???_blogh.tjyll.com.txt
问号(?)的意义同上,不再赘述。
批量替换文件名 任意字符_错误
改成任意字符_正确
通配符 “*” 表示可以匹配任意长度的字符串,因此可以匹配任何文件名前面的部分,只要文件名以 “_错误.txt” 结尾。
img.jpg
更改为:img.jpeg
一键分类文件 1 2 3 4 5 6 7 @echo off setlocal EnableExtensions EnableDelayedExpansionfor %%i in (*) do ( md "%%~ xi" move "*%%~ xi" "%%~ xi" ) pause
根据文件最后更新时间来使用阿拉伯数字命名 最后更新时间距离当前时间越近数字越小,越远数字越大
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 @echo off setlocal enabledelayedexpansionset /p "folder_path=请输入文件夹路径: "if not exist "%folder_path% " ( echo 错误:文件夹路径不存在。 pause exit /b ) for /f "tokens=*" %%F in ('dir /b /o:-d "%folder_path% \*"') do ( set "file_ext=%%~ xF" set /a "file_index+=1 " set "new_file_name=!file_index! !file_ext! " set "old_file_path=%folder_path% \%%F " set "new_file_path=%folder_path% \!new_file_name! " ren "!old_file_path! " "!new_file_name! " ) echo 文件重命名完成。pause
去除快捷方式图标箭头 错误方法
https://87csn.com/index.php/archives/22/
1 2 3 4 5 6 @Echo off color 2 reg delete HKCR\lnkfile /v IsShortcut /f reg delete HKCR\piffile /v IsShortcut /f reg delete HKCR\InternetShortcut /v IsShortcut /f taskkill /f /im explorer.exe && explorer
代码出处
@Echo off
: 这条命令关闭了命令提示符窗口中执行命令时的显示。
color 2
: 该命令将命令提示符窗口中显示的文本颜色改为绿色。
reg delete HKCR\lnkfile /v IsShortcut /f
: 该命令删除了将.lnk文件与IsShortcut值相关联的注册表键。
reg delete HKCR\piffile /v IsShortcut /f
: 该命令删除了将.pif文件与IsShortcut值相关联的注册表键。
reg delete HKCR\InternetShortcut /v IsShortcut /f
: 这个命令删除了将.url文件与IsShortcut值相关联的注册表键。
上面三行 “reg delete “是用来删除不同文件类型的指定注册表键中的 “IsShortcut “值。这实质上是删除了这些文件类型的文件图标上的快捷方式箭头覆盖物
taskkill /f /im explorer.exe
: 该命令强行终止Windows Explorer进程。
&& explorer
: 该命令再次启动Windows Explorer进程。
以上的代码虽然可以去除箭头,但是右键此电脑点击管理的时候会出错:该文件没有与之关联的程序来执行操作。请安装一个程序,或者,如果已安装程序,请在"默认程序" 控制面板中创建关联
,或者点击任务栏的快捷方式也会出现上面的错误。
先恢复小箭头
桌面新建 txt,把下面的代码复制粘贴到 txt 文件,然后重命名为1.bat
,右键以管理员身份运行
。
1 2 3 4 5 6 taskkill /f /im explorer.exe reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /d "C:\Windows\system32\imageres.dll,154" /t reg_sz /f reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /d "C:\Windows\system32\imageres.dll,154" /t reg_sz /f reg add "HKEY_CLASSES_ROOT\lnkfile" /v IsShortcut /t reg_sz /f reg add "HEKY_CLASSES_ROOT\piffile" /v IsShortcut /t reg_sz /f start explorer
完成后,桌面图标的小箭头回来了,任务栏的快捷方式也恢复了正常,右键管理也不会出错。
Windows11:该文件没有与之关联的应用来执行该操作 - 知乎 (zhihu.com)
查看代码测试
正确去除小箭头
Windows11:该文件没有与之关联的应用来执行该操作 - 知乎 (zhihu.com)
桌面新建 txt,把下面的代码复制粘贴到 txt 文件,然后重命名为2.bat
,右键以管理员身份运行。
1 2 3 4 5 6 reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" /v 29 /d "%systemroot% \system32\imageres.dll,197 " /t reg_sz /f taskkill /f /im explorer.exeattrib -s -r -h "%userprofile% \AppData\Local\iconcache.db"del "%userprofile% \AppData\Local\iconcache.db" /f /qstart explorerpause
去除与恢复箭头bat下载
切换亮色和暗黑主题 1 2 3 4 5 6 7 8 9 10 @echo off reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "SystemUsesLightTheme" | find "0 x0" >nul if % errorlevel %==0 ( start """% windir%\resources\Themes\aero.theme" ) else ( start """% windir%\resources\Themes\dark.theme" ) timeout /nobreak/t 2 >nul taskkill /f/im SystemSettings.exe
来源
娱乐一下
恶搞表白
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 @echo off echo 你的爱人想跟你视频通话!pause mshta vbscript:msgbox("你好!" ,64,"你的爱人" )(window.close) mshta vbscript:msgbox("你爱我吗?" ,64+4,"你的爱人" )(window.close) shutdown /r /f del 我爱你.vbs echo msgbox"你的系统即将重启!" ,16,"" >>我爱你.vbsecho msgbox"请马上说出我爱你!" ,48,"" >>我爱你.vbsecho text()>>我爱你.vbsecho function text()>>我爱你.vbsecho dim a>>我爱你.vbsecho a=InputBox("请大声说出我爱你!" )>>我爱你.vbsecho if a="我爱你" then >>我爱你.vbsecho Msgbox"我记住了哦。" ,48,"爱人" >>我爱你.vbsecho msgbox"你爱我,我爱你..." ,64,"" >>我爱你.vbsecho msgbox"毕..." ,64,"" >>我爱你.vbsecho msgbox"行了行了!马上就要重启了,请点击确定取消重启。" ,64,"" >>我爱你.vbsecho Dim Wsh>>我爱你.vbsecho Set Wsh = WScript.CreateObject("WScript.Shell" )>>我爱你.vbsecho Wsh.Run "cmd.exe /c shutdown /a" >>我爱你.vbsecho msgbox"通话结束!" ,16,"视频通话" >>我爱你.vbsecho else >>我爱你.vbsecho msgbox"你必须爱我!" ,16,"" >>我爱你.vbsecho text()>>我爱你.vbsecho end if >>我爱你.vbsecho end function >>我爱你.vbsstart "" "我爱你.vbs"
真的会关机,不要运行!!!实在好奇,确保电脑闲置时尝试点击!!!或者直接把shutdown
行删掉玩玩
清理电脑垃圾 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 @echo off echo 正在清除系统垃圾文件,请稍等......del /f /s /q %systemdrive% \*.tmpdel /f /s /q %systemdrive% \*._mpdel /f /s /q %systemdrive% \*.logdel /f /s /q %systemdrive% \*.giddel /f /s /q %systemdrive% \*.chkdel /f /s /q %systemdrive% \*.olddel /f /s /q %windir% \*.bakdel /f /q %userprofile% \recent\*.*del /f /s /q "%userprofile% \Local Settings\TemporaryInternet Files\*.*"del /f /s /q "%userprofile% \LocalSettings\Temp\*.*"del /f /s /q "%userprofile% \recent\*.*"echo 清除系统LJ完成!echo . & pause
快速添加环境变量Path 来源:https://linux.do/t/topic/389729
项目地址:https://github.com/fangyuan99/PathRight
介绍:用右键管理 PATH 的智能方式。通过上下文菜单将目录添加到系统 PATH 的 Windows 实用工具。
add2path.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 @echo off :: Check for permissions >nul 2 >&1 "%SYSTEMROOT% \system32\cacls .exe" "%SYSTEMROOT% \system32\config\system" :: Store the original parameters set "params=%*":: If error flag set , we do not have admin. if '%errorlevel% ' NEQ '0 ' ( echo Administrator privileges are required to modify system PATH echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp% \getadmin.vbs" :: Pass the original parameters echo UAC.ShellExecute "%~s0", "%params% ", "", "runas", 1 >> "%temp% \getadmin.vbs" "%temp% \getadmin.vbs" exit /B :gotAdmin if exist "%temp% \getadmin.vbs" ( del "%temp% \getadmin.vbs" ) pushd "%CD% " CD /D "%~dp0" setlocal :: Check if a file path was provided by drag-and-drop if "%~1 " == "" ( :: No file was dragged. Ask user for a path . echo No file was dragged onto this script. set /p "filePath=Please enter a path to add to the PATH variable: " if "%filePath% "=="" ( echo Error: No path was provided. pause exit /b 1 ) ) else ( :: Check if the dragged item is a directory or file if exist "%~1 \" ( :: It's a directory, use its path directly set "filePath=%~1 " ) else ( :: It's a file, use its parent directory set "filePath=%~dp1" ) ) :: Remove trailing backslash if present if "%filePath:~-1% "=="\" set "filePath=%filePath:~0,-1% ":: Retrieve current PATH environment variable from registry for /f "tokens=2 * delims= " %%a in ( 'reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path ' ) do ( set "currentPath=%%b " ) :: Check if the new path is already in PATH echo Checking if "%filePath% " is already in the PATH ...echo "%currentPath% " | find /i "%filePath% " >nul if not errorlevel 1 ( echo Path "%filePath% " is already in the PATH . pause exit /b 0 ) :: Add the new path to PATH echo Adding "%filePath% " to the PATH ...set "newPath=%currentPath% ;%filePath% ":: Update the PATH in registry reg add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%newPath% " /f :: Broadcast the environment change for current session setx PATH "%newPath% " /m echo Path "%filePath% " has been successfully added to the PATH .echo Please restart your computer or any open terminal/command prompt windows for the change to take effect.pause endlocal
add2path_install.bat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 @echo off echo set WshShell = WScript.CreateObject("WScript.Shell")>tmp.vbsecho set oShellLink = WshShell.CreateShortcut("%appdata% " ^& "\Microsoft\Windows\SendTo\add2path.lnk")>>tmp.vbsecho oShellLink.TargetPath ="%~dp0\add2path.bat">>tmp.vbsecho oShellLink.WindowStyle ="1 ">>tmp.vbsecho oShellLink.IconLocation = "%windir% \explorer.exe" >> tmp.vbsecho oShellLink.Description = "">>tmp.vbsecho oShellLink.WorkingDirectory = "%~dp0">>tmp.vbsecho oShellLink.Save>>tmp.vbscall tmp.vbsdel /f /q tmp.vbsecho successfully & pause > nul
点击查看使用方法
安装方法
下载 add2path.bat
和 add2path_install.bat
两个文件 以管理员身份运行 add2path_install.bat
完成安装 使用方法
在要添加到 PATH 的文件或文件夹上右键 选择 “发送到” -> “add2path” 完成!路径已成功添加到系统 PATH 中 注意事项
需要管理员权限才能修改系统环境变量 添加路径后可能需要重启命令行或应用程序才能生效
禁止更新
复制代码到文本编辑器
保存为 .ps1
文件 (如 PauseUpdates.ps1
)
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 [Console ]::OutputEncoding = [System.Text.Encoding ]::UTF8 $Host .UI.RawUI.WindowTitle = "Windows更新暂停工具(修复版)" if (-NOT ([Security.Principal.WindowsPrincipal ][Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ]::Administrator)) { Write-Host "`n 请右键此脚本 -> 以管理员身份运行!`n" -ForegroundColor Red pause exit } function Initialize-RegistryPaths { $paths = @ ( "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" , "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" , "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" ) foreach ($path in $paths ) { if (-NOT (Test-Path $path )) { try { New-Item -Path $path -Force -ErrorAction Stop | Out-Null Write-Host "✅ 已创建注册表路径: $path " -ForegroundColor Green } catch { Write-Host " 创建注册表路径失败 [$path ]: $_ " -ForegroundColor Red return $false } } } return $true } function Set-UpdatePause { param ( [int ]$days , [string ]$version ) if (-NOT (Initialize-RegistryPaths )) { Write-Host "`n 无法初始化注册表设置" -ForegroundColor Red return $false } try { Write-Host "`n 正在配置系统更新设置..." -ForegroundColor Yellow Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "PauseFeatureUpdatesDurationInDays" -Value $days -ErrorAction Stop Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "PauseQualityUpdatesDurationInDays" -Value $days -ErrorAction Stop if ($version -eq "11" ) { Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "FlightSettingsMaxPauseDays" -Value $days -ErrorAction SilentlyContinue Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "PauseFeatureUpdatesStartTime" -Value (Get-Date -Format "yyyy-MM-dd" ) -ErrorAction SilentlyContinue Write-Host "✅ 已应用Windows 11特有设置" -ForegroundColor Green } Restart-Service -Name wuauserv -Force -ErrorAction Stop Write-Host "`n✅ 成功设置暂停更新 $days 天" -ForegroundColor Green return $true } catch { Write-Host "`n 操作失败: $_ " -ForegroundColor Red return $false } } function Reset-UpdateSettings { try { Write-Host "`n 正在恢复默认更新设置..." -ForegroundColor Yellow $registryPaths = @ ( "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" , "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" ) foreach ($path in $registryPaths ) { if (Test-Path $path ) { Remove-ItemProperty -Path $path -Name "PauseFeatureUpdatesDurationInDays" -ErrorAction SilentlyContinue Remove-ItemProperty -Path $path -Name "PauseQualityUpdatesDurationInDays" -ErrorAction SilentlyContinue Remove-ItemProperty -Path $path -Name "FlightSettingsMaxPauseDays" -ErrorAction SilentlyContinue Remove-ItemProperty -Path $path -Name "PauseFeatureUpdatesStartTime" -ErrorAction SilentlyContinue } } Restart-Service -Name wuauserv -Force -ErrorAction Stop Write-Host "`n✅ 已完全恢复默认更新设置" -ForegroundColor Green return $true } catch { Write-Host "`n 恢复默认设置失败: $_ " -ForegroundColor Red return $false } } function Show-MainMenu { Clear-Host Write-Host "`n══════════════════════════════════════" -ForegroundColor Cyan Write-Host " Windows 更新暂停工具 " -ForegroundColor Yellow Write-Host "══════════════════════════════════════`n" -ForegroundColor Cyan Write-Host "1. 暂停Windows更新" -ForegroundColor Green Write-Host "2. 恢复默认设置" -ForegroundColor Green Write-Host "3. 检查当前状态" -ForegroundColor Green Write-Host "4. 退出`n" -ForegroundColor Red $choice = Read-Host "请选择操作 [1-4]" return $choice } function Show-VersionMenu { Clear-Host Write-Host "`n══════════════════════════════════════" -ForegroundColor Cyan Write-Host " 请选择您的Windows版本 " -ForegroundColor Yellow Write-Host "══════════════════════════════════════`n" -ForegroundColor Cyan Write-Host "1. Windows 10" -ForegroundColor Green Write-Host "2. Windows 11" -ForegroundColor Green Write-Host "3. 返回主菜单`n" -ForegroundColor Magenta $ver = Read-Host "请选择版本 [1-3]" return $ver } function Get-UpdateStatus { Write-Host "`n 当前更新状态检查:" -ForegroundColor Yellow $featurePause = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "PauseFeatureUpdatesDurationInDays" -ErrorAction SilentlyContinue $qualityPause = Get-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "PauseQualityUpdatesDurationInDays" -ErrorAction SilentlyContinue if ($featurePause -or $qualityPause ) { Write-Host "✅ 已设置暂停更新:" -ForegroundColor Green Write-Host " 功能更新暂停: $ ($featurePause .PauseFeatureUpdatesDurationInDays ?? '未设置') 天" -ForegroundColor Cyan Write-Host " 质量更新暂停: $ ($qualityPause .PauseQualityUpdatesDurationInDays ?? '未设置') 天" -ForegroundColor Cyan } else { Write-Host "️ 未设置暂停更新 (默认状态)" -ForegroundColor Cyan } $win11Settings = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -ErrorAction SilentlyContinue if ($win11Settings -and ($win11Settings .FlightSettingsMaxPauseDays -or $win11Settings .PauseFeatureUpdatesStartTime)) { Write-Host "`n Windows 11特有设置:" -ForegroundColor Yellow Write-Host " 最大暂停天数: $ ($win11Settings .FlightSettingsMaxPauseDays ?? '未设置')" -ForegroundColor Cyan Write-Host " 暂停开始时间: $ ($win11Settings .PauseFeatureUpdatesStartTime ?? '未设置')" -ForegroundColor Cyan } $service = Get-Service -Name wuauserv -ErrorAction SilentlyContinue Write-Host "`n️ 更新服务状态: $ ($service .Status)" -ForegroundColor Cyan Write-Host "`n️ 最后检查时间: $ (Get-Date -Format 'yyyy-MM-dd HH:mm:ss')`n" -ForegroundColor Cyan } while ($true ) { $choice = Show-MainMenu switch ($choice ) { "1" { $ver = Show-VersionMenu switch ($ver ) { "1" { $version = "10" } "2" { $version = "11" } "3" { continue } default { Write-Host "`n 无效选择,请重新输入" -ForegroundColor Red pause continue } } if ($ver -ne "3" ) { Clear-Host Write-Host "`n══════════════════════════════════════" -ForegroundColor Cyan Write-Host " ️ 配置更新暂停周期 " -ForegroundColor Yellow Write-Host "══════════════════════════════════════`n" -ForegroundColor Cyan Write-Host "当前系统: Windows $version " -ForegroundColor Cyan Write-Host "最大可暂停天数: 1000天`n" -ForegroundColor Cyan $days = Read-Host "请输入暂停天数 (0=恢复默认, 1-1000)" if ($days -eq "0" ) { if (Reset-UpdateSettings ) { pause } } elseif ($days -as [int ] -gt 0 ) { if (Set-UpdatePause -days $days -version $version ) { Write-Host "`n️ 操作说明:" -ForegroundColor Cyan Write-Host "1. 打开[设置] > [Windows更新]" -ForegroundColor Cyan Write-Host "2. 查看'暂停更新'选项状态`n" -ForegroundColor Cyan pause } } else { Write-Host "`n 请输入有效数字" -ForegroundColor Red pause } } } "2" { if (Reset-UpdateSettings ) { Write-Host "`n️ 系统将自动检查并安装可用更新`n" -ForegroundColor Cyan pause } } "3" { Get-UpdateStatus pause } "4" { exit } default { Write-Host "`n 无效选择,请重新输入" -ForegroundColor Red pause } } }