Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows

วิธีใช้ Windows Defender ผ่าน Command Prompt

ใช้ Windows Defender จาก Command Prompt

Windows Defender เป็นแอนติไวรัสเริ่มต้นใน Windows 10 และ 11 ไม่แพ้ซอฟต์แวร์บุคคลที่สาม ด้านการใช้ทรัพยากรระบบ Windows Defender เป็นที่ดีที่สุด แม้ GUI ใช้งานง่าย แต่ใช้ผ่าน Command Prompt ก็ได้ เหมาะสำหรับสร้าง Script หรือ Scheduled Tasks

Command line ของ Windows Defender ทำได้ทุกอย่างพื้นฐาน: สแกนแบบต่างๆ, แสดง/กู้คืนไฟล์ Quarantine, เพิ่ม Dynamic Signatures, ลบ/อัปเดต Virus Definitions บทความนี้จะสอนการใช้งาน

ใช้ Windows Defender จาก Command Prompt

ต้องมีสิทธิ์ Administrator: ค้นหา Command Prompt ใน Start Menu เลือก "Run as Administrator" หรือคลิกขวาเลือก "Run as Administrator"

วิธีใช้ Windows Defender ผ่าน Command Prompt

Windows Defender GUI มี 3 แบบสแกน คำอธิบายดังนี้:

Quick Scan: เร็ว ตรวจสอบที่พบมักพบมัลแวร์/ไวรัส เช่น Registry Keys และ Startup Folders ใช้เวลานาที ใน Command line ใช้ -ScanType 1

Full Scan: สแกนลึกทั้งระบب ขึ้นอยู่กับจำนวนไฟล์ อาจใช้หลายชั่วโมง ใน Command line ใช้ -ScanType 2

Custom Scan: สแกนลึก Drive/Folder/File เฉพาะ ใน Command line ใช้ -ScanType 3 พร้อม Switch ระบุ Path

คำสั่งสแกนต่างๆ

Quick Scan:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 1
วิธีใช้ Windows Defender ผ่าน Command Prompt

Full Scan: เปลี่ยน 1 เป็น 2

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 2
วิธีใช้ Windows Defender ผ่าน Command Prompt

Custom Scan: แทนที่ "D:\Folder\Path" ด้วย Path จริง

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType 3 -File "D:\Folder\Path"
วิธีใช้ Windows Defender ผ่าน Command Prompt

Boot Sector Scan: สแกน Boot Sector สำหรับไวรัสติด Master Boot Record

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Scan -ScanType -BootSectorScan

ยกเลิกการสแกน: กด Ctrl + C

วิธีใช้ Windows Defender ผ่าน Command Prompt

จัดการไฟล์ Quarantine

Windows Defender ย้ายไฟล์เสี่ยงไป Quarantine แต่ False Positive เกิดขึ้นได้ หากคิดว่าไฟล์ถูกต้องถูกย้าย ไปกู้คืนได้ง่าย

  1. แสดงไฟล์ Quarantine ทั้งหมด:
    "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Restore -ListAll
  2. จากรายการ ระบุชื่อไฟล์ แล้วรัน:
    "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -Restore -Name "FileName"
    ไฟล์จะกลับไปที่ตำแหน่งเดิม

อัปเดต Virus Definitions

Windows Defender อัปเดตอัตโนมัติ แต่หากต้องการตรวจสอบ ให้รัน:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
วิธีใช้ Windows Defender ผ่าน Command Prompt

ลบและกู้คืน Security Updates

หากทดสอบแอปหรือเขียน Script อาจอยากดูการทำงานของ Windows กับ Security Updates ล่าสุดและรุ่นก่อน Command Prompt สามารถลบ (และกู้คืน) Security Definitions ได้

หมายเหตุ: ขอแนะนำให้กู้คืน Definitions เป็นเวอร์ชันล่าสุดหลังลบ เพื่อให้ PC ได้รับการป้องกันจากภัยคุกคามล่าสุด

ลบ Definitions:

  • คืนค่าเป็น Default หรือ Backup ล่าสุด (สร้างอัตโนมัติเมื่ออัปเดต):
    "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -All
  • ลบเฉพาะ Dynamic Signatures ที่ดาวน์โหลดมา:
    "%ProgramFiles%\Windows Defender\MpCmdRun.exe" -RemoveDefinitions -DynamicSignatures
วิธีใช้ Windows Defender ผ่าน Command Prompt

กู้คืน Definitions:

"%ProgramFiles%\Windows Defender\MpCmdRun.exe" -SignatureUpdate
วิธีใช้ Windows Defender ผ่าน Command Prompt

ตัวเลือก Command-line ของ Windows Defender ใช้งานง่ายและเข้าใจง่าย สำหรับเคล็ดลับ Windows เพิ่มเติม ดูวิธีแก้ Windows 11 Snipping Tool ที่มีปัญหา และรายละเอียดของ TrustedInstaller ว่าจริงๆ ต้องการหรือไม่