Running a program on remote computer from a network share

Posted on


Well going all in: assigning all my 72 point as bounty to this question!

How to run a command line program on remote Windows computers with out installing additional software (aka ssh). All recommendations on the web/stackoverflow fail following basic needs:

  1. The remote program shall be able to access a network share (read/write)!
  2. The output of the program shall be captured (back to controlling computer)
  3. Automat-able to run from a script (i.e. python)

I have looked at following:

  1. WMI — can run a program but it cannot access network shares and output is not visible (fire and pray method?)
  2. WinRM — supposedly can access network shares but setup is beyond complicated (seems to require not self-signed certificates and entring password, which fails C)
  3. PsExec — cannot run executable from network path

Environment: all Win 7, can run as local admin


I would recommend PowerShell remoting. But answer to question how? depends very much on environment (domain/ workgroup) and your rights (on server/ within domain).

That’s one command in AD environment:

Set-ADComputer -TrustedForDelegation $true -Identity <your target server>

And later:

Invoke-Command -ComputerName <target server> -ScriptBlock { your command }

… but that will not work in workgroup environment, so I guess you need to be more specific here.

The psexec tool, originally created by Sysinternals, but now a part of Microsoft Technet, should do what you need.

With it you can run any command on a remote Windows computer, including copying over any executable, running it, and returning the results. You don’t have to install anything on the remote computer.

Of course you have to have administrative or equivalent rights on the target machine to perform execution. In essence, if you cannot remote desktop or login to the machine, you won’t be able to use it. That’s pretty obvious.

Here is the product page:

You can find many tutorials and guides on the Internet on how to use it.

I don’t understand what you mean by “it cannot access the network”.

Do the following:

  1. Write a script, a batch file, or an executable so that if you physically copy it to the target machine and double-click on it, it does everything you need (connects to the remote share and reads / writes data to it.) How to do that is beyond this question and actually depends on the technology you are going to use to write the script.
  2. Use psexec to run it on another target machine.

My understanding is that you are currently failing step 1, but the current question is about step 2.

Have you tried mapping the network share to a drive letter on the remote PC? PSExec would then be able to see the files in that share as local.

Leave a Reply

Your email address will not be published. Required fields are marked *