Abinash
Abinash

Reputation: 481

IIS7 does not start my Exe file by Process Start but it's running in task bar

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

Upvotes: 1

Views: 6342

Answers (2)

SAI BALAJI
SAI BALAJI

Reputation: 31

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.

Upvotes: 3

Abinash
Abinash

Reputation: 481

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

Upvotes: 1

Related Questions