How to execute EXE file on Windows 2008 using ASP.NET and IIS7? I have tried to run code below but it seems do not work. The code is executed without any error but I do not see Notepad in Processes list. Everything works fine if I use ASP.NET developer server but not with IIS7.
string enginePath = "notepad";
var password =开发者_高级运维 new System.Security.SecureString();
foreach (char character in ConfigurationManager.AppSettings["Credentials"])
password.AppendChar(character);
var p = new Process
{
StartInfo =
{
FileName = enginePath,
UseShellExecute = false,
}
};
p.StartInfo.UserName = "Administrator";
p.StartInfo.Password = password;
p.Start();
In response to security concerns Microsoft has continually increased the isolation of the IIS process such that you can not (or I have not found a work around which will allow you to...) invoke anything outside the IIS application domain directly. You can build a Windows service which can use WCF channels to cross that boundary indirectly. That service (configured to be allowed to interact with the desktop) can in turn launch your Notepad.exe.
It is a bit of a kludge to make it happen and I will certainly be interested to see if someone else has a better answer.
I have removed lines below and it suddenly started working. I can't explain how it is possible to run exe under IIS7 account but it is working.
p.StartInfo.UserName = "Administrator";
p.StartInfo.Password = password;
精彩评论