1

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;
  process.Start()process.WaitForExit();

And I have tried following solutions

IIS7 does not start my Exe file by Process Start

Foo.cmd won't output lines in process

System.Diagnostics.Process.Start not work from an IIS

nothing helped.If any one knows please help me

Community
  • 1
  • 1
Abinash
  • 471
  • 3
  • 13
  • 2
    Services cannot interact with the desktop. By messing with your apppool settings, you might fudge this to work. Not recommended. What's the point of spawning a UI process from a webserver? – spender Oct 21 '16 at 10:08
  • Thanks spender for the comment. Actually I tried app pool Identity to local system and user also but it's also not working – Abinash Oct 21 '16 at 10:11
  • To do what? Have IIS open a calc.exe instance? Why? – spender Oct 21 '16 at 10:11
  • I am just trying this sample actual use is I want to access QuickBook application from IIS server to desktop the same problem I am facing there. – Abinash Oct 21 '16 at 10:15
  • 2
    That's not going to happen. The server has no access to your desktop at all. It works locally because you are both the client and the server. – Mark Fitzpatrick Oct 21 '16 at 11:29
  • Thanks Mark but application processes is starting in system and i can see it in Task Manager with processes Id how its happening??? – Abinash Oct 21 '16 at 11:33
  • 1
    Are you trying to make a web wrapper around the quickbooks client application? That's highly unlikely to work. application service processes (like IIS) and GUI client applications don't play nice. You get one unexpected messagebox and it grinds to a halt. – Nick.Mc Oct 21 '16 at 13:34

2 Answers2

3

Try setting the value of the Load User profile to True for the ApplicationPool that you are using for your application.

You can just select the application pool and select advanced settings under advanced setting you can find this option.

This worked for me.

ApplicationPool Settings screen shot

EDIT : but as spender said it is not advisable to launch an EXE from your IIS server as this may open up some way for hackers to attack on your application.

spender
  • 117,338
  • 33
  • 229
  • 351
SAI BALAJI
  • 31
  • 3
1

I have searched a lot and finally I find a solution,It my be helpful to some one.

Solution :

Asp.net 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 Asp.net and Winform can communicates through .Net Remoting or other Inter process communication technologies. When the Asp.net 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 Asp.net process.

.Net Remoting is the solution to solve this problem (refer this link .NET Remoting with an easy example )

Download sample from Click Here

Abinash
  • 471
  • 3
  • 13