0

I want to be able to execute a command prompt on a remote server, and I need to issue several commands in the console and capture the output - I would like to return that output back to me.

This looks like how to execute the command prompt locally (not adding in the commands that I wish to run with in the console.) I have read somewhere on SO yesterday on how to do that part. Now what I would like to do is open the command prompt on the remote computer, run a specific executable (from a specific remote folder) with in the console(command Prompt); basically the executable processes some files, and then return the output of that command back to my application.

The console does not need to appear to the user - it just needs to run and exit when I am done, however since I am going to be programmatically writing execution commands in the console - I am not sure that processInfo will work and that I need either PSExec or WMI.

I have read this: Executing command in command prompt with redirection on a C# .aspx page

How can I accomplish my goal of remotely executing the console and interactively adding commands to the console and retrieving the output?

In regards to PowerShell - it has to be enabled on the remote computers. "Because PowerShell Remoting presents a security risk, it has to be enabled even within an Active Directory domain. " I do not want to require my user to do this - they know a username and password for the administrative accounts.

Community
  • 1
  • 1
Ken
  • 2,518
  • 2
  • 27
  • 35
  • So, basically, you're reinventing PowerShell remoting? If the servers are running reasonably recent stocks of Windows, you won't need to do that, since you could use PowerShell remoting with far greater ease. Before this, PsExec was pretty much the go-to tool, but that uses some serious voodoo under the covers to get it done, the kind you probably won't want to repeat yourself in C#. – Jeroen Mostert Nov 08 '16 at 21:40
  • @JeroenMostert C# can execute the PSExec so I would not need to reinvent, simply issue the PSExec commands from c#. I am not sure if Power Shell will work for me - I need to execute the commands on a win2003 server and win2008 server, I also need to output the files back to my application, which will then use those files to process additional remote commands and then I exit the remote console and provide results back to the user. – Ken Nov 08 '16 at 21:57

0 Answers0