Windows 運行時常見「指令引用的記憶體無法 read/written」、「內部應用程式錯誤」、IE 超連結失效、Media Player 無法播放、遊戲啟動報錯等問題,多半源於系統 DLL 註冊遺失或損毀。一條 for 迴圈指令即可批次重新註冊 System32 目錄下所有 DLL,快速修復大部分註冊相關故障。
for %1 in (%windir%\system32\*.dll) do regsvr32.exe /s %1
| 元素 | 說明 |
|---|---|
for %1 in (...) | CMD 批次迴圈,%1 為迴圈變數 (批次檔中寫 %%1) |
%windir%\system32\*.dll | 系統目錄下所有 .dll 檔案 |
regsvr32.exe /s | 靜默註冊 DLL (不顯示成功對話框) |
do regsvr32.exe /s %1 | 對每個 DLL 執行註冊 |
cmd → Ctrl+Shift+Enter (以管理員身分執行)。@echo off
echo 正在重新註冊系統 DLL,請稍候...
for %%i in (%windir%\system32\*.dll) do regsvr32.exe /s "%%i"
echo 完成,建議重新開機。
pause
for %1 in (%windir%\system32\*.dll) do regsvr32.exe /s %1
for %1 in (%windir%\SysWOW64\*.dll) do regsvr32.exe /s %1
Get-ChildItem "$env:windir\system32\*.dll" | ForEach-Object {
regsvr32 /s $_.FullName
if ($LASTEXITCODE -ne 0) { Write-Warning "註冊失敗: $($_.Name)" }
}
regsvr32 會靜默失敗 (因 /s 不顯示),無副作用。sfc /scannow (系統檔案檢查)、DISM /Online /Cleanup-Image /RestoreHealth (元件存儲修復)、乾淨啟動排查、或修復安裝/重裝系統。這條指令是 Windows 維護工具箱中的「急救鑰」,雖不保證 100% 有效,但成本極低、風險極小,遇到上述疑難雜症時值得優先嘗試。