How to run an exe on remote machine using cmd?

22,095

One way would be with PsExec:

psexec \\server_ip "path_to_where_the_file_should_go/file.exe"

Other methods include remote Powershell, telnet, SSH.

Share:
22,095

Related videos on Youtube

meJustAndrew
Author by

meJustAndrew

Updated on September 18, 2022

Comments

  • meJustAndrew
    meJustAndrew over 1 year

    If I want to copy a file on a remote server, I use the following command in cmd:

    xcopy \\source_file server_ip\path_to_where_the_file_should_go\file.exe
    

    The command above works and now I want to run that executable on the server.

    Do you have any idea how I can do that?

    Note: I don't have access to the machine on which this command will be run on, so I won't be able to install any additional application on it, I can just send it a command line script which it will run.

    In other words, I have a remote machine on which I am only able to send commands (cmd/Power shell). This machine has an .exe which I copy to another machine using the command above. Now I want to run it on this second machine, from the first machine, using a cmd or power shell script.

    • simlev
      simlev over 5 years
      SSH could be a method, do you have SSH client and server on the relevant machines? It should come native with the most recent Windows editions, it is activated with "Add feature...".
    • Vomit IT - Chunky Mess Style
      Vomit IT - Chunky Mess Style over 4 years
      @meJustAndrew .... How about something like .... Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME which I've had rather good success running. If the exe is on the local drive of the machine, then starting the exe with that sort of logic should do the trick. Permissions will likely be the key though.
  • meJustAndrew
    meJustAndrew over 5 years
    I have seen this solution on the internet, but the problem is that I am unable to install additional applications (like PsExec) on the target machine...
  • simlev
    simlev over 5 years
    What do you mean by install? It's a simple executable to be run locally.
  • meJustAndrew
    meJustAndrew over 5 years
    I mean that I am running this command as part of a VSTS release pipeline, and the command will be run on a random machine which needs to connect to a server and to run the file.exe. I don't have rights to connect to any of these machines which will need to run psexec in order to make sure that the psexec is there...