Microsoft Remote Desktop Command Line

  

There will be times as a Windows Administrator that you will need to reboot or shutdown a remote computer or server.

In this video, I will show you guys how to enable Remote desktop RDP using Command Line CMD. Commands: reg add 'HKEYLOCALMACHINE SYSTEM CurrentControlS.

In this tutorial, I’ll show you two easy methods for rebooting and shutting down remote computers.

The first method uses a built in Windows command and the second method uses PowerShell.

Check it out.

Windows Shutdown Command

Microsoft Terminal Services Client (MSTSC) is the command line interface to run the Microsoft Remote Desktop (RDP) client. It enables you to establish a remote connection to somebody else’s computer or to Remote Desktop Session Host (RDSH) servers as if it is in front of you and edit existing Remote Desktop Connection (.rdp) configuration files. Creates connections to Remote Desktop Session Host servers or other remote computers, edits an existing Remote Desktop Connection (.rdp) configuration file, and migrates legacy connection files that were created with Client Connection Manager to new.rdp connection files. Run a script in the remote session when it logs in. I can think of three ways to do this: Use the 'Alternate Shell' RDP file property. This runs a specified program in place of explorer.exe on login; you can use it to run 'cmd.exe /c your script' for instance. Windows Remote Desktop and remote connections are manageable from the command line. In this video, learn what's available and practice a few commands.

Windows systems has a built in shutdown command that can be used to restart or shutdown local and remote computers.

The command is shutdown.

To use this command just open the windows command prompt and type shutdown.

To view the full list of command options type shutdown /? in the CMD window.

Microsoft Remote Desktop Command Line Download

There are several command line switches, below I list the most useful options.

/s – Shutdown the computer

/r – restart computer

Microsoft Remote Desktop Command Line Command

/m computer – Specify the remote computer

/l – Log off

/t xxx – Set the time out period before shutdown to xxx seconds

/c “comment” – Message to display on the screen before restart or shutdown

Now lets move onto some examples

Restart or Shutdown Examples with Command Line

In these examples, I’ll be on PC1 and will initiate a remote restart or shutdown on PC2.

I’ll be using the /r switch in these examples, you can change them to /s to shutdown instead of restart.

Example 1: Restart Remote Computer

By default, this will prompt the remote computer and give it about a minute before it restarts.

The pop up below is what a Windows 10 system will display.

Example 2: Restart With a Custom Message

You may want to display a custom message to the logged on users, to do that just use the /c command.

Below is the pop up on the remote computer with the custom message.

Example 3: Immediate Restart no Countdown

If you want to immediately restart with no countdown or message use this command.

If you want a longer countdown just specify the seconds /t 60

Example 4: Log user off remote computer

Windows remote desktop command line options

If you just want to log a user off the remote computer use this command.

Restart or Shutdown with Powershell

Microsoft Remote Desktop Command Line

Here are a few examples of how you can restart or shutdown computers with PowerShell.

The downside to PowerShell is it doesn’t have as many options as the shutdown command. There is no option to prompt users with a custom message or provide a countdown.

Example 1: Use Powershell to restart a computer

This command will immediately restart a remote computer. The -Force option will force a restart even if a user is logged on.

Example 2: Use PowerShell to shutdown a computer

This command will shutdown a remote computer. Use the -Force to force a shutdown even if a user is logged on.

Example 3: Use PowerShell to restart a list of computers

This is handy if you have several computers to restart. Just list all the computers you want in a text file and add that to the PowerShell command.

Example 4: Use PowerShell to shutdown down two computers

Have fun!

Used by thousands of Professionals to Simplify and Automate Active Directory Management.

Reboot Windows Remote Desktop Command Line

-->

Applies to: Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012

Learn about the available Remote Desktop Services (Terminal Services) command-line tools, with descriptions and links for more detailed information.

Note

To find out what's new in the latest version, see What's New in Remote Desktop Services in Windows Server.

Microsoft Remote Desktop Command Line Tutorial

CommandDescription
changeChanges the Remote Desktop Session Host server settings for sign in, COM port mappings, and install mode.
change logonEnables or disables logons from client sessions on an Remote Desktop Session Host server, or displays current logon status.
change portLists or changes the COM port mappings to be compatible with MS-DOS applications.
change userChanges the install mode for the Remote Desktop Session Host server.
chglogonEnables or disables logons from client sessions on an Remote Desktop Session Host server, or displays current logon status.
chgportLists or changes the COM port mappings to be compatible with MS-DOS applications.
chgusrChanges the install mode for the Remote Desktop Session Host server.
flattempEnables or disables flat temporary folders.
logoffSigns out a user from a session on an Remote Desktop Session Host server and deletes the session from the server.
msgSends a message to a user on an Remote Desktop Session Host server.
mstscCreates connections to Remote Desktop Session Host servers or other remote computers.
qappsrvDisplays a list of all Remote Desktop Session Host servers on the network.
qprocessDisplays information about processes that are running on an Remote Desktop Session Host server.
queryDisplays information about processes, sessions, and Remote Desktop Session Host servers.
query processDisplays information about processes that are running on an Remote Desktop Session Host server.
query sessionDisplays information about sessions on an Remote Desktop Session Host server.
query termserverDisplays a list of all Remote Desktop Session Host servers on the network.
query userDisplays information about user sessions on an Remote Desktop Session Host server.
quserDisplays information about user sessions on an Remote Desktop Session Host server.
qwinstaDisplays information about sessions on an Remote Desktop Session Host server.
rdpsignEnables you to digitally sign a Remote Desktop Protocol (.rdp) file.
reset sessionEnables you to reset (delete) a session on an Remote Desktop Session Host server.
rwinstaEnables you to reset (delete) a session on an Remote Desktop Session Host server.
shadowEnables you to remotely control an active session of another user on an Remote Desktop Session Host server.
tsconConnects to another session on an Remote Desktop Session Host server.
tsdisconDisconnects a session from an Remote Desktop Session Host server.
tskillEnds a process running in a session on an Remote Desktop Session Host server.
tsprofCopies the Remote Desktop Services user configuration information from one user to another.

Additional References