Monday, 24 October 2016

How to start Exe file using process start c# in IIS

How to start Exe file using process start c# in IIS I have searched a lot and finally I find solution.So I am writing here my be it will helpful to some one.
Problem : I have created a project with process start in c# it's running in local visual studio build,when I hosting it in IIS it's not running but it's starting the processes and nothing is displaying I checked it in task manager.Code sample:
Process process = new Process();
process.StartInfo.FileName = "calc.exe";
process.StartInfo.UseShellExecute = false;
And I have tried following solutions
nothing helped,Finally I Find solution my self.
Solution : with IIS runs as a service application, which means that it runs under another Window Station and Desktop. However, in Windows, the default visible Window Station and Desktop is WinSta0\Default, which is where the Shell(explorer.exe) runs. So the .exe you created is displayed in an invisible desktop.

Actually, Window Station and Desktop is a good sandbox for GUI security, since Windows do not want the normal GUI application to communication other Services applications through Windows Message.

To display the GUI from a non-visible service application, you have to break the security sandbox of WinSta0\Default, which is a little complex.

However, if you want to create a visible process, it is really hard. Normally, the recommended solution is creating a second GUI application like Winform, and the and Winform can communicates through .Net Remoting or other Inter process communication technologies. When the wanted to create the visible notepad process, it can tell the Winform client through Net Remoting, then Winform will simply Proces.Start notepad.exe on behalf of process.

.Net Remoting :
    .Net Remoting is the solution to solve this problem(refer this link .NET Remoting with an easy example ) I am attaching the sample application to run calculator from IIS Server Click To Download

Have any queries comment here :)



  1. Hey, I want to thank you so much, your solution was the only one that worked for me. Greetings!!!

  2. thank you so much, only solution for me :)