IIS7 does not start my Exe file by Process Start

2019-01-11 07:44发布

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.

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

 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 ClientBin in an Application in IIS.

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

{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

<?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

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.com and http://technet.microsoft.com/en-us/sysinternals/bb896653 Problem was while using x86 application on a x64 IIS in combination with verb=runas flag. Now application is set to anycpu (Perhaps that does not matter) and verb on ProcessStartInfo is not set to anything.

3条回答
成全新的幸福
2楼-- · 2019-01-11 08:18

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

  1. Open Application Pools
  2. Find your pool (by default DefaultAppPool)
  3. Click on "Advanced settings"
  4. Change Identity to "LocalSystem"

Hopefully it will help somebody...

查看更多
够拽才男人
3楼-- · 2019-01-11 08:37
var p = new Process
{
    StartInfo =
    {
        FileName = Path,    
        UseShellExecute = false,
    }
};
p.Start();
查看更多
别忘想泡老子
4楼-- · 2019-01-11 08:40

Edit:

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

  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.

Original answer:

You need to assign FullControl security permissions for the IIS AppPool\DefaultAppPool user, 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.

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.

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

Screenshot:

enter image description here enter image description here

查看更多
登录 后发表回答