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.
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.This is covered in more detail in this Scripting Guy article.
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 asnet 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
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: http://sourceforge.net/projects/rce/