Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know PsExec is perfect for sending files over a computer on a network and then execute it on that remote computer, however I can't use PsExec because I'm developing a piece of software and I can't have PsExec as a dependency (for legal reasons etc.).

What's the easiest way to achieve the execution part on a remote computer? Is it really that hard? I am already copying the .bat file with xcopy... I just need to run it.

share|improve this question
have a look at WMI or DCOM – zero_r Sep 1 '10 at 9:48
up vote 5 down vote accepted

You can execute a script, or binary, remotely using WMI. This is a minimal example, written in VBS, which runs the batch file C:\test.cmd located on the remote computer FCSD-ISC1.

strComputer = "FCSD-ISC1"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objWMIService.Create "C:\test.cmd", null, null, intProcessID

This is covered in more detail in this Scripting Guy article.

share|improve this answer

I recommend mounting the C$ share, testing for the .\Temp directory (creating if it doesn't exist), and copying there. (There is an "admin$" administrative share, but I recommend against using it.)

You can do this from the command line via net use * \\servername\c$ /user:domain/account or specify a drive as net use t: \\servername\c$ /user:domain/account

This should be well documented in MSDN. If writing for a script, there are a lot of examples in the Microsoft Script Center Repository

share|improve this answer
Even if you mount the remote share, execution of the batch file would occur on the local computer. @Luca says he's using xcopy place the file on the remote machine. – jscott Sep 1 '10 at 11:18
Yup, I missed that. – gWaldo Sep 1 '10 at 14:57

I know is not relevant anymore but for the sake of completness(this page is high on google) i'll add here RemCom, which is an open source version of Psexec get it here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.