Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 does not start my Exe file by Process Start

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 which 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.

like image 547
Nasenbaer Avatar asked Dec 07 '11 11:12

Nasenbaer


2 Answers

Giving Full Control permission to any web users is always a very bad idea. For a better solution, please see Process.Start doesn't work in IIS

like image 200
Jack Ceramic Avatar answered Oct 11 '22 09:10

Jack Ceramic


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 hereenter image description here

like image 44
MichaelS Avatar answered Oct 11 '22 10:10

MichaelS