| 功能 | CMD (tasklist/taskkill) | PowerShell (Get-Process/Stop-Process) | WMIC (WMI) | 備註 |
|---|---|---|---|---|
| 列出所有程序 | tasklist | Get-Process / ps | wmic process list brief | PS 物件最豐富 |
| 含服務關聯 | tasklist /svc | Get-CimInstance Win32_Service | Select Name,ProcessId,State | wmic service list | svchost 解析必備 |
| 依 PID 結束 | taskkill /PID 1234 /F | Stop-Process -Id 1234 -Force | wmic process where "ProcessId=1234" delete | /F 強制 |
| 依映像名稱結束 | taskkill /IM notepad.exe /F /T | Stop-Process -Name notepad -Force | wmic process where "Name='notepad.exe'" delete | /T 連帶子程序 |
| 依 CPU/記憶體排序 | — | ps | Sort-Object CPU -Desc | Select -First 10 | wmic process get Name,PageFileUsage,WorkingSetSize /format:table | PS 最強 |
| 完整路徑/命令列 | wmic process get ExecutablePath,CommandLine | (Get-Process -Id 1234).Path / .StartInfo.Arguments | 同上 | 排查掛馬/異常啟動參數 |
| 樹狀父子關係 | — | Get-Process | Format-Table Id,ProcessName,@{N='Parent';E={(Get-CimInstance Win32_Process -Filter "ProcessId=$($_.Id)").ParentProcessId}} -Auto | wmic process get ProcessId,ParentProcessId | 分析程序鏈 |
# CMD
for /f "tokens=5" %a in ('netstat -ano ^| findstr :8080') do taskkill /PID %a /F
# PowerShell (更優雅)
$pid = (Get-NetTCPConnection -LocalPort 8080 -ErrorAction SilentlyContinue).OwningProcess
if ($pid) { Stop-Process -Id $pid -Force }
# PowerShell 掃描可疑特徵
Get-Process | Where-Object {
$_.Path -notlike "C:\Windows\*" -and
$_.Path -notlike "C:\Program Files*" -and
($_.CPU -gt 50 -or $_.WorkingSet64 -gt 500MB)
} | Select-Object Id,ProcessName,Path,CPU,WS | Format-Table -AutoSize
# 結合簽章驗證 (需管理員)
Get-Process | Where-Object { $_.Path } | ForEach-Object {
$sig = Get-AuthenticodeSignature $_.Path
if ($sig.Status -ne 'Valid') { $_ | Select Id,ProcessName,Path,@ {N='SigStatus';E={$sig.Status}} }
}
原文提到的 `reg add ... Image File Execution Options` 即為 **Image File Execution Options (IFEO)** 劫持技術,常被惡意軟體用於將合法程式重導向惡意程式/偵錯器。
# 檢查所有 IFEO
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options" /s /f "Debugger"
# 刪除特定程式劫持
reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\notepad.exe" /v Debugger /f
# 批次清理所有 Debugger 值 (謹慎!可能誤刪合法偵錯設定)
# 建議先匯出備份
# 註冊表啟動項
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Run"
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
# 排程工作
schtasks /query /fo LIST /v | findstr "Ready"
# PowerShell 統一介面
Get-CimInstance Win32_StartupCommand | Select Name,Command,Location,User
| 功能 | 指令 | 說明 |
|---|---|---|
| 網路設定 | ipconfig /all | IP、MAC、DNS、DHCP、租約 |
| 路由表 | route print / route print -4 | IPv4 路由、介面公制值 |
| ARP 快取 | arp -a | IP-MAC 對應、偵測 ARP 欺騙 |
| DNS 快取 | ipconfig /displaydns / ipconfig /flushdns | 查看/清除 |
| 連接埠監聽 | netstat -ano / netstat -anob (需管理員) | PID 對應、程式名稱 |
| 防火牆規則 | netsh advfirewall firewall show rule name=all | 匯出/分析 |
| DirectX 診斷 | dxdiag /t dxdiag.txt | 匯出報告 |
| 群組原則 | gpedit.msc / rsop.msc / gpresult /h report.html | 結果集/HTML 報表 |
| 系統資訊 | systeminfo / msinfo32 | 硬體/軟體/熱修補/網路 |
# 將 208.111.145.0/24 導向黑洞 (172.21.1.0 需為不可達 IP)
route add 208.111.145.0 mask 255.255.255.0 172.21.1.0
# 永久生效加 -p
route -p add 208.111.145.0 mask 255.255.255.0 172.21.1.0
# 刪除
route delete 208.111.145.0
# 更優雅:Windows 防火牆封鎖規則
netsh advfirewall firewall add rule name="Block 208.111.145.0/24" dir=out action=block remoteip=208.111.145.0/24
CIMCmdlets (Get-CimInstance)$PROFILE 或 GitHub Gist,需要時即取即用任務管理員只是 GUI 門面,底層能力全在 **Tasklist/Taskkill、PowerShell CIM/WMI、Netsh、Reg.exe** 等命令列工具。熟練掌握這些 CLI 技巧,不僅能在 GUI 失效時「照常作業」,更能將運維動作**腳本化、自動化、納入 CI/CD 與合規稽核**,是從「會修電腦」進化為「系統工程師」的關鍵技能包。