Categories: Remote access

Enable remote desktop from command line (CMD)

Remote desktop can be enabled/disabled by opening My computer properties and then by changing the settings in the ‘Remote‘ tab. We can do the same by editing registry key settings. This is explained below. Remote desktop is also called Terminal services or TS or RDP. This is an in-built remote desktop software for Windows users.

Enable remote desktop from CMD

  • Open registry editor by running regedit from Run.
  • Go to the node
    HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server
  • Change the data of the value fDenyTSConnections to 0.

We can enable remote desktop from Windows command line by running the following command.

reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

To disable remote desktop we need to run the below command.

reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f

Reboot or logoff is not required after running the above command. I have tested this on Windows 11 and Windows 10 and it has worked fine. It would work fine on Windows 11 and Windows 10 too.

Enable Remote assistance:

reg add "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal Server" /v fAllowToGetHelp /t REG_DWORD /d 1 /f

Relevant Posts:
Run command for Remote Desktop
Remote desktop and Terminal Services : Frequently asked questions

Srini

View Comments

  • add user as well
    net user username password /add
    net localgroup administrators USER_ACCOUNT /add

  • HUGE help, I'm in MA, remote system in CA, no one in the office right now. I'm running Teamviewer for remote access and I just upgraded. Post upgrade the system is almost entirely hung, can't do much of anything (though I can run a command prompt). I enabled RDP, logged on and reinstalled TV. Thanks so much!

  • I wonder can anyone write a script like that to automate this whole thing (including firewall, elevated cmd line etc)? C+ may be. May be even for a reasonable donation))

  • lol lol lol thank you Matthew Bradley, I couldn't find this vital piece of information for like 20 minutes on google.

  • Yeah, this doesn't work. You're missing one critical step - opening the firewall
    netsh firewall set service remotedesktop enable

  • Hi, i need to disable/enable remote desktop on my server during the time i run some automation. The tip you suggested works on all of my servers except for the one that i really need. Would you know of any other parameter that could disable that registry key?

  • im in the same network with my junior,i want to enable his remote access over the network.i can ping his computer and respond.i have his computer name and i.p address.network users are not in domain,they are in workgroup.how can you assist me without going to the user's desk?

    • You could use PsExec to open an remote command prompt. Thus you need to download PsTools Suite from Microsoft Tech-Net.

Share
Published by
Srini

Recent Posts

Manage Print Jobs in Windows 11 & 10 Using PowerShell

Use PowerShell to list, pause, resume, and cancel print jobs in Windows 11 and Windows…

7 days ago

Add New User Account from Command Prompt (CMD)

Create local or domain user accounts from Command Prompt in Windows 11 and Windows 10…

4 years ago

Delete directory from command line [Rmdir]

Do you want to delete a directory from Windows Command Prompt (CMD)? This post explains…

4 years ago

TaskKill: Kill process from command line (CMD)

We can kill a process from GUI using Task manager. If you want to do…

4 years ago

Kill Chrome from command line

Chrome is definitely the stable browser compared to other ones and it has been my…

4 years ago

Find Windows OS version from command line

Windows has multiple command line utilities that can help find the version of the Windows…

4 years ago