6

I want to connect to the rdp server and execute the command on the server via command line. Is it possible to do with one line-command?

3 Answers 3

5

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.

2
  • 1
    there is no more Programs tab in win 10
    – guai
    Commented Aug 11, 2021 at 17:06
  • I dropped on an edit. Commented Aug 11, 2021 at 21:55
3

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.

2
  • 1
    No, I need to do this without additional software.
    – artem
    Commented Jun 27, 2013 at 2:52
  • 2
    Powershell is not additional software. No more additional than RDP
    – Nick.Mc
    Commented Jan 2, 2017 at 0:22
0

Create new advance Task Scheduler with even triger:

"Run only when user is logged on" true => show window
"Start the task only if the computer is on APC power" false

Run command i.e ClearLock.exe for extra security in my situation command will be trigger automatic on connect. Or CMD.exe, Compare to short-cut in startup or in Run registry this method don't have delay in execute

Create Event:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .