I have a native EXE that converts a file based on command line arguments. Provided, I know how to give full path names of the input and output files, can I run such an EXE from my app service when some button is pressed and wait till the output file is created? Converting to DLL is not an option.
Asked
Active
Viewed 1,580 times
1 Answers
1
As far as I know, we could run a native exe in the azure app service.
But we couldn't directly pass the parameter to the native exe.
You need write a web application or something else for the user to type in the input parameter.
Then you could use Process.Start method to run the exe.
About how to do it , you could refer to this code sample.
I use ASP.NET MVC to get the input parameter then send the parameter to the exe and get the result.
public ActionResult Index()
{
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = Server.MapPath("/exe/Sum.exe"),
//Arguments could be replaced
Arguments = "1 2",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadLine();
// do something with line
Response.Write( " The result is : " + line);
}
//await getResultAsync();
return View();
}
Result:

Brando Zhang
- 22,586
- 6
- 37
- 65
-
Thanks, that gives me hope. I will try it out. The EXE I use creates some hidden windows and controls for processing, for example, a RichEdit control for RTF. That was the primary reason, it didn't work in a DLL. Azure doesn't allow it but other web hosts do. I wonder if such things will be allowed in the exe. – user173399 Sep 21 '17 at 08:53
-
My EXE won't run because it uses a hidden RichEdit internally and hence GDI+ calls. Azure Sandbox doesn't allow this as per https://stackoverflow.com/questions/28293505/process-start-in-azure-website. But anyway, I will accept your answer because I didn't mention GDI+ in my original question. – user173399 Sep 22 '17 at 03:44