1

Let's say I have a VM (windows) running on MS-Azure. Lets say I have programs Y and Z on that VM which are logging some critical data. Let's say I also have a program X inside the VM which accepts some arguments and returns some of that critical data based on filters.

Now, I am building a front end webapp, An ASP.NET website, where the owner of the above mentioned VM can login and view data that program X can provide.

I already have my logging programs running inside the VM and program X installed. How can I access an exectuble inside a VM, pass arguments to it, run it and get results back to me? is this doable? Can someone suggest how I can achieve this?

Thanks.

sparta93
  • 3,684
  • 5
  • 32
  • 63

2 Answers2

0

If your program X doesn't involve GUI, you may try to run it on the PS Remote Session. Here is a good guide about how to configure the powershell remote.

Also, here is the article about the port need opening on the firewall.

By default PowerShell will use the following ports for communication (They are the same ports as WinRM)

TCP/5985 = HTTP

TCP/5986 = HTTPS

If it involves GUI, as far as I know, the only solution is remoting to the VM with RDP.

Besides, it is not a good idea to expose the WinRM or RDP ports on the internet. I would suggest you to create a VPN on Azure and use WinRM or RDP over VPN.

-1

You can run another executable using the System.Diagnostic.Process class:

// Start the child process.
 Process p = new Process();
 // Redirect the output stream of the child process.
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardOutput = true;
 p.StartInfo.FileName = "X.exe";
 p.Start();
 // Do not wait for the child process to exit before
 // reading to the end of its redirected stream.
 // p.WaitForExit();
 // Read the output stream first and then wait.
 string output = p.StandardOutput.ReadToEnd();
 p.WaitForExit();

Copied from: run console application in C# with parameters

Community
  • 1
  • 1
OzieGamma
  • 426
  • 3
  • 10