.net IIS7 不通过进程启动启动我的 Exe 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8414514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:05:46  来源:igfitidea点击:

IIS7 does not start my Exe file by Process Start

.netsilverlightiis-7

提问by Nasenbaer

I've read a lot of articles. But as far as I know I've done all. On local computer VS2010 all works fine. The problem occurs only when working on IIS7 Server.

我读了很多文章。但据我所知,我已经完成了所有工作。在本地计算机 VS2010 上一切正常。只有在 IIS7 服务器上工作时才会出现此问题。

I want to start a exe file wich works great on server if I start it manually from Windows Explorer.

如果我从 Windows 资源管理器手动启动它,我想启动一个在服务器上运行良好的 exe 文件。

 Dim fiExe As New IO.FileInfo(IO.Path.Combine(diBase.FullName, "ClientBin\ConvertAudio.exe"))
    Dim SI As New ProcessStartInfo(fiExe.FullName, args)
    SI.Verb = "runas"
    SI.UseShellExecute = True
    SI.WorkingDirectory = fiExe.Directory.FullName
    Dim P As Process = Process.Start(SI)
    P.PriorityClass = ProcessPriorityClass.Idle

I've converted the directory ClientBinin an Application in IIS.

我已经ClientBin在 IIS 中的应用程序中转换了目录。

But when using the service I receive this error (callback in Silverlight application):

但是在使用该服务时,我收到此错误(Silverlight 应用程序中的回调):

{System.Security.SecurityException ---> System.Security.SecurityException: Sicherheitsfehler
   bei System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   bei System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   bei System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)
   --- Ende der internen Ausnahmestapelüberwachung ---
   bei System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   bei System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   bei System.Net.WebClient.WebClientWriteStream.<Dispose>b__3(IAsyncResult ar)}

I've tried to store the file "clientaccesspolicy.xml" in same directory like ClientBin

我试图将文件“clientaccesspolicy.xml”存储在同一个目录中 ClientBin

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="*">
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource path="/" include-subpaths="true"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy> 

Still the same message. Any idea?

还是一样的消息。任何的想法?

ISS7 Commandline configuration

ISS7 Commandline configuration

permission in Windows Explorer

permission in Windows Explorer

* new info - verb *When using this function

* 新信息 - 动词 *使用此功能时

Dim startInfo As New ProcessStartInfo(fiExe.FullName)
            Dim V As String = ""
            For Each verb As String In startInfo.Verbs
                V &= V & ", "
            Next
            Throw New Exception("Verbs=" & V)

I receive this result:

我收到这个结果:

Verbs=, , , , , , ,

动词=, , , , , , ,

* Solution found *I've found the solution while using http://www.fiddler2.comand http://technet.microsoft.com/en-us/sysinternals/bb896653Problem was while using x86 application on a x64 IIS in combination with verb=runasflag. Now application is set to anycpu (Perhaps that does not matter) and verbon ProcessStartInfo is not set to anything.

* 找到解决方案 *我在使用http://www.fiddler2.comhttp://technet.microsoft.com/en-us/sysinternals/bb896653时找到了解决方案 问题是在 x64 IIS 上使用 x86 应用程序时与verb=runas旗帜结合。现在应用程序设置为 anycpu(也许这无关紧要)并且verbProcessStartInfo 没有设置为任何内容。

回答by MichaelS

Edit:

编辑:

After a long journey, me and Nasenbaerhave found the following. The possible reasons for IIS to fail run an EXE are:

经过长途跋涉,我和纳森巴尔找到了以下内容。IIS 无法运行 EXE 的可能原因是:

  1. Lack of permissions for IIS Users, such as the application pool user, or the Network service (in IIS6).
  2. x86 EXE running on x64 machine issues.
  3. Typical EXE failure issues such as missing dependencies.
  1. 缺少 IIS 用户的权限,例如应用程序池用户或网络服务(在 IIS6 中)。
  2. 在 x64 机器上运行的 x86 EXE 问题。
  3. 典型的 EXE 失败问题,例如缺少依赖项。

Original answer:

原答案:

You need to assign FullControl security permissions for the IIS AppPool\DefaultAppPooluser, on the directory the EXE is located in. This is the user that is trying to run the process (assuming you are using the DefaultAppPool), and without the proper permissions, it is unable to do so.

您需要IIS AppPool\DefaultAppPool在 EXE 所在的目录上为用户分配 FullControl 安全权限。这是尝试运行该进程的用户(假设您正在使用DefaultAppPool),如果没有适当的权限,则无法执行所以。

When you run the EXE manually, you are using the Windows logged in user. This is why you are able to lunch it manualy. The IIS uses the Application Pool user.

当您手动运行 EXE 时,您使用的是 Windows 登录用户。这就是您可以手动午餐的原因。IIS 使用应用程序池用户。

To add permissions just do the following:

要添加权限,只需执行以下操作:

  1. Go to directory properties
  2. Security tab
  3. Edit.. -> Add the IIS AppPool\DefaultAppPool
  4. Check for it the FullControl
  1. 转到目录属性
  2. 安全选项卡
  3. 编辑.. -> 添加 IIS AppPool\DefaultAppPool
  4. 检查它 FullControl

Screenshot:

截图

enter image description hereenter image description here

enter image description hereenter image description here

回答by Arkady

What helped me is this: Setting in Application Pool Identity = LocalSystem

对我有帮助的是:在应用程序池标识中设置 = LocalSystem

  1. Open Application Pools
  2. Find your pool (by default DefaultAppPool)
  3. Click on "Advanced settings"
  4. Change Identity to "LocalSystem"
  1. 开放应用程序池
  2. 找到您的池(默认为 DefaultAppPool)
  3. 点击“高级设置”
  4. 将身份更改为“LocalSystem”

Hopefully it will help somebody...

希望它会帮助某人...

回答by Raja Fawad

var p = new Process
{
    StartInfo =
    {
        FileName = Path,    
        UseShellExecute = false,
    }
};
p.Start();