Connect to RDP & execute command from CLI
Solution 1:
For Windows Server 2003 this is feasible using the "Programs" tab of the "Options" in the Microsoft Remote Desktop Connection client. There you can specify a program to run after logon in lieu of Windows Explorer. If what you want to run will work on a %SystemRoot%\system32\cmd.exe /c (command and arguments here)
then you're all set. If you need more than a single command then call a script instead.
Save the Remote Desktop client settings to a file. Pass the filename on the command line after mstsc.exe
. That's your single-command solution.
For newer versions of the Windows you'd probably have the best luck using the RemoteApp functionality in Remote Desktop Services.
Solution 2:
That you would want to connect to a server via RDP, which is by its very nature GUI-centric, so that you can run a command-line command, seems to me completely counter-intuitive.
I think what you want is a remote administration tool such as psexec, or Powershell remoting.