Windows 內建「記事本」不只能編輯文字,配合 ftype 指令更能在病毒劫持 .exe 執行關聯時,強制將所有執行檔導向記事本開啟,讓惡意程式無法啟動,進而手動清除。以下為完整實戰流程。
ftype exefile=notepad.exe %1 將註冊表 HKEY_CLASSES_ROOT\exefile\shell\open\command 的預設值改為記事本,所有雙擊 .exe 行為均改為以記事本載入,病毒主程式、啟動項、服務均無法正常執行,達到「靜態隔離」效果。
cmd → Ctrl+Shift+Enter。ftype exefile=notepad.exe %1ctfmon.exe、explorer.exe)也會以文字形式開啟。C:\Windows\System32\cmd.exe → 打勾「一律使用此應用程式開啟 .exe 檔案」→ 確定。此後雙擊 .exe 即進入命令列。ftype exefile="%1" %*| 指令 | 效果 |
|---|---|
ftype exefile=notepad.exe %1 | 所有 .exe 以記事本開啟(%1 = 檔案本身) |
ftype exefile="%1" %* | 還原預設:直接執行 .exe(%* = 傳遞所有參數) |
ftype | 列出所有檔案類型與關聯命令 |
ftype txtfile | 查詢單一類型關聯 |
ftype、regedit 亦無法執行,請改用 WinPE 離線修復登錄:HKLM\SYSTEM → 修改 HKEY_CLASSES_ROOT\exefile\shell\open\command 值為 "%1" %*。.scr、.com、.bat、.cmd、.pif 等可執行副檔名,只需將 exefile 換成對應 ProgID。掌握 ftype 與 assoc 指令,不僅能應對病毒劫持,更能在批次腳本中動態切換檔案關聯,是系統管理員的必備輕量級武器。