หากต้องการใช้ฟีเจอร์ Remote Desktop โดยไม่เปิด Windows Settings panel สามารถเปิดใช้งานผ่าน Command Prompt หรือ Windows PowerShell ได้ หากมี remote desktop client บนมือถือหรือคอมพิวเตอร์อื่น จะสามารถเชื่อมต่อและใช้ PC ระยะไกลได้
Remote Desktop เป็นฟีเจอร์ดังของ Windows 11/10 ให้เชื่อมต่อ 2 คอมพิวเตอร์/มือถือ เพื่อให้เข้าถึงคอมพิวเตอร์อีกเครื่องจากระยะไกล สามารถแก้ปัญหาผ่านมือถือ หรือทำงานอื่นๆ ตามต้องการ ต้องมี Remote Desktop client เช่น Microsoft Remote Desktop บนมือถือเพื่อเชื่อมต่อ
ปกติเปิด/ปิด Remote Desktop ได้จาก Windows Settings (System > Remote Desktop) แต่ถ้า Settings panel เปิดไม่ได้ และต้องการเปิด Remote Desktop ให้ใช้ command line
เปิดใช้งาน Remote Desktop ด้วย Command line
ขั้นตอน:
- เปิด Command Prompt หรือ PowerShell ด้วยสิทธิ์ Administrator
- ตั้งค่า fDenyTSConnections REG DWORD เป็น 0
- เพิ่ม Firewall rule
- รีสตาร์ทคอมพิวเตอร์
- เริ่มใช้ Remote Desktop ใน Windows 10
คำสั่งต่างกันระหว่าง Command Prompt และ PowerShell
1] เปิดใช้งาน RDP firewall ด้วย Command Prompt

เปิด Command Prompt แบบ Administrator (ค้นหาใน Taskbar คลิก Run as administrator) รันคำสั่ง:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
ค่าเริ่มต้นของ fDenyTSConnections คือ 1 คำสั่งนี้เปลี่ยนเป็น 0
รันคำสั่งต่อไป:
netsh advfirewall firewall set rule group="remote desktop" new enable=yes
คำสั่งนี้เพิ่มและอัปเดต 3 rules ใน Firewall เพื่อใช้ Remote Desktop ได้
2] เปิดใช้งาน RDP ด้วย Windows PowerShell

เปิด Windows PowerShell แบบ Administrator รันคำสั่ง:
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0
คำสั่งนี้เปลี่ยน fDenyTSConnections เป็น 0 รันคำสั่งเพิ่ม Firewall rules:
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
หลังจากนั้นใช้ Remote Desktop ใน Windows 10 ได้แล้ว
หากต้องการปิด Remote Desktop ด้วย Command Prompt และ PowerShell ทำตามขั้นตอนด้านล่าง
เกี่ยวข้อง: Remote Desktop option is greyed out
ปิดใช้งาน Remote Desktop ด้วย Command Prompt หรือ PowerShell
ขั้นตอน:
- เปิด Command Prompt หรือ PowerShell แบบ Administrator
- ตั้งค่า fDenyTSConnections REG DWORD เป็น 1
- เพิ่ม Firewall rule
- Restart computer
ปิด Remote Desktop ด้วย Command Prompt
ตั้งค่า fDenyTSConnections กลับเป็น 1 (ค่าเริ่มต้น):
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
ลบ rules จาก Firewall:
netsh advfirewall firewall set rule group="remote desktop" new enable=No
ปิด Remote Desktop ด้วย PowerShell
เปลี่ยน fDenyTSConnections เป็น 1:
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 1
คำสั่งที่ 2 ลบ rules จาก Firewall:
Disable-NetFirewallRule -DisplayGroup "Remote Desktop"
ขอให้ใช้งาน Remote Desktop สะดวกสบายครับ!
