IIS7 does not start my Exe file by Process Start
Asked Answered
F

4

11

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.

Flowerdeluce answered 7/12, 2011 at 11:23 Comment(0)
M
15

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

Mariannemariano answered 7/12, 2011 at 11:53 Comment(15)
Thank you a lot MichaelS. It sounds like it should work. I feel stupid but I do not know where to find the FullControl flag you are talking about. I've added an image. Please, can you try to provide me some details of menus to find the FullControl?Flowerdeluce
@Nasenbaer: Go to the actual folder in the Explorer, not in the IIS Manager. Let me know if you need a screenshot.Mariannemariano
Hi MichaelS. Thanks again. Before I've postet here in Stackoverflow I already checked this issu. But because I saw all to Full access on IIS User, I could not catch the problem. Please, yes, can you provide me the menu in Windows Explorer (English should be fine) to work in? I've added a new picture to show where I looked in.Flowerdeluce
@Nasenbaer: I've added the screenshot, it seems you are in the right place. Verify that the Application pool user (usually called DefaultAppPool) is inside SERVER-IIS\Users role.Mariannemariano
Hi Michael. Thanks for the screenshots. Like you can see in mine, I already have added "Everyone = Vollzugriff (full control)" also as IIS. The lucky thing is that I have no "DefaultAppPool" which I can select. I cannot do the same like you. What IIS do you use?Flowerdeluce
@Nasenbaer: I use IIS7 as well. But if you allowed full control for everyone, then it should include IIS users as well. So i'm beginning to think maybe other issues can be happening. Do you see the process run in the task manager? Even for a second? Maybe you can see under which user it runs?Mariannemariano
Hi. No. Process does not start because of permission. I have no more idea how to proceed.Flowerdeluce
@Nasenbaer: I'm out of ideas as well. Sorry. Maybe try to open a bounty when and if the time comes. I'll post here if something comes to mind. Good luck!Mariannemariano
Thanks a lot Michael. You've helped me to not loose myself!! Great day!Flowerdeluce
I've added some news about verbs. Perhaps that helps?Flowerdeluce
@Nasenbaer: The verbs doesn't trigger anything to me. I've seen someone suggesting to turn off the UAC on a similar question. Have you tried that?Mariannemariano
Good idea. But UAC is already off. Is is possible that you can test it in your side if a commandline app works?Flowerdeluce
I think it works now. Problem was that the application was created as x86 and did not work smooth when using the "verb=runas" flag on a x64 system. Your help was great! thanks.Flowerdeluce
@Nasenbaer: Glad you have worked it out! I will update my answer with all the possible reasons we found.Mariannemariano
@Mariannemariano in my case, when I try to edit security from directory, its giving me this message. "DemoAppPool" Name not Found. How to overcome this?Portulaca
F
8

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

Fallow answered 21/10, 2013 at 20:38 Comment(3)
It's should work, but It is not sequrity safe approach.Phosphor
This was my solution. Thanks!Electrochemistry
Thanks a lot! I have spend long time and finally found a working solution.Darreldarrell
A
1

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

Apart answered 10/2, 2022 at 20:27 Comment(0)
S
-2
var p = new Process
{
    StartInfo =
    {
        FileName = Path,    
        UseShellExecute = false,
    }
};
p.Start();
Scrubby answered 7/12, 2011 at 12:2 Comment(1)
That I've already done like described. Sorry but that does not work.Flowerdeluce

© 2022 - 2024 — McMap. All rights reserved.