@echo off :: 自動檢查並請求系統管理員權限 >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" if '%errorlevel%' NEQ '0' ( echo 正在要求系統管理員權限... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "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" echo =================================================== echo 正在停用 Windows Update、SysMain 並清理快取... echo =================================================== :: 1. 強制結束鎖死中的更新與背景傳輸進程 echo [1/5] 強制關閉背景更新行程... taskkill /F /FI "SERVICES eq wuauserv" >nul 2>&1 taskkill /F /FI "SERVICES eq bits" >nul 2>&1 :: 2. 停止更新相關服務 echo [2/5] 停止更新與快取服務... net stop wuauserv /y >nul 2>&1 net stop bits /y >nul 2>&1 net stop dosvc /y >nul 2>&1 net stop sysmain /y >nul 2>&1 net stop cryptSvc /y >nul 2>&1 :: 3. 將服務啟動類型改為「已停用」 echo [3/5] 永久停用更新與 SysMain 服務... sc config wuauserv start=disabled >nul 2>&1 sc config bits start=disabled >nul 2>&1 sc config dosvc start=disabled >nul 2>&1 sc config sysmain start=disabled >nul 2>&1 sc config UsoSvc start=disabled >nul 2>&1 sc config WaaSMedicSvc start=disabled >nul 2>&1 :: 4. 停用 Windows Update 排程任務,防止系統夜間自我喚醒 echo [4/5] 停用背景更新喚醒排程... schtasks /Change /TN "\Microsoft\Windows\WindowsUpdate\Scheduled Start" /Disable >nul 2>&1 schtasks /Change /TN "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan" /Disable >nul 2>&1 schtasks /Change /TN "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan Static" /Disable >nul 2>&1 :: 5. 清理已下載的暫存更新檔案以釋放硬碟空間 echo [5/5] 清理 SoftwareDistribution\Download 暫存檔... del /f /s /q "%SystemRoot%\SoftwareDistribution\Download\*" >nul 2>&1 rmdir /s /q "%SystemRoot%\SoftwareDistribution\Download" >nul 2>&1 mkdir "%SystemRoot%\SoftwareDistribution\Download" >nul 2>&1 :: 重新啟動一般運作必需的密碼編譯服務 net start cryptSvc >nul 2>&1 echo. echo =================================================== echo 處理完成!Windows Update 與 SysMain 已徹底停用。 echo =================================================== pause