1

Possible Duplicate:
How to execute a command in a remote computer?

here is my question.

I have a remote computer LIQIANDEV and on it there is a command C:\test\test.cmd. Now I have a web server LIQIANTEST, I want to run the test.cmd on remote computer LIQIANDEV using C# code, how should I do this?

Thanks a lot for your help.

Community
  • 1
  • 1
QianLi
  • 1,088
  • 12
  • 22
  • Flag for Server Fault. Also @ColinGrealy is correct. – Cole Tobin Jul 02 '12 at 03:43
  • You need to write and install a server app on LIQIANDEV, then connect to it from LIQIANTEST – Blorgbeard Jul 02 '12 at 03:43
  • 2
    Check this out http://stackoverflow.com/questions/428276/how-to-execute-a-command-in-a-remote-computer someone already asked a similar question some years ago, check it out. – bntzio Jul 02 '12 at 03:44

2 Answers2

1

You can run a program on another computer using PsExec, which is part of Microsoft's SysInternals. Therefore, you could use c# to create a local process that runs the PsExec command.

Alternatively, you can use Windows PowerShell Remoting to run a powershell script on another computer. Once again, this could be kicked off using c#.

I think you can also do it with WMI or perhaps even RDP.

Michael
  • 8,891
  • 3
  • 29
  • 42
-3

Short answer: you can't. There are all kinds of barriers in place to prevent you from being able to do exactly that.

Longer answer: If you explain what you're trying to accomplish by running this code, there might be a better way to do it.

Colin Grealy
  • 615
  • 4
  • 12