Was not able to run cmd.exe process from back end side RRS feed

  • Question

  • User2029114928 posted

    Hi everyone,
    I want to run cmd.exe process from back end side of  ASP.NET application with Process class. Process returns error code 1.
    I have read for such cases ,if you want run process from IIS application pool, you need to :
    1) Add user with administrator privileges
    2) Allow  to IIS Admin  service interact with desktop

    Note: I have read there is no permission to run process from IIS application pool need to add permission .By default IIS doesn't allow to do it
    I am using windows Server 2012 R2 and there is no such service.
    Please could you help me to overcome issue?

    Wednesday, May 29, 2019 11:05 AM

All replies

  • User753101303 posted


    Seems to be https://stackoverflow.com/questions/4237225/allow-service-to-interact-with-desktop-in-windows but I'm really not convinced this is needed (and using admin privilege when not absolutely required is likely a bad idea too).

    What do you really want to run then through cmd ? You don't expect to show a command prompt on the client side ? IMO you may have simpler solution.

    Wednesday, May 29, 2019 11:53 AM
  • User2029114928 posted


    I want to run python code from cmd. I do not need to show cmd to the client, I just want to run process.

    I know how to allow to interact with desktop ,the problem is that higher IIS 6.0 or 7.0 there is no IIS Admin service.

    I have read there is no permission to run process from IIS application pool need to add permission .

    Wednesday, May 29, 2019 12:25 PM
  • User753101303 posted

    AFAIK interacting with the desktop is when you need to see a UI when logged.

    I would rather try to directly start c:\yourfolder\python.exe rather than trying to run cmd.exe (what you are doing then is unclear).

    Another convenient approach is to run a c:\test\test.bat file that you can then update as needed at least for testing (and you can start with something very simple to just make sure it works).

    For now I believe you do start your process but that you have then some error in what you are doing later. Redirecting the output to a file (you'll need a write permission for the process that runs your app) could be a good idea to better understand what really happens.

    For example the batch file could be :
    c:\<folder>\python.exe c:\<folder>\script.py >c:\<folder>\output.txt

    The first script would just write to the standard output and so the message should be written to the output.txt file. It would allow to see basic stuff works before moving forward.

    Edit: for example https://stackoverflow.com/questions/40532626/how-to-integrate-python-with-asp-net (just get rid of cmd.exe)

    Wednesday, May 29, 2019 1:29 PM
  • User-893317190 posted

    Hi Grig Vardanyan,

    By default, application pool of iis uses ApplicationPoolIdentity which has limited permission.

    You could change the application pool's identity to local system to assign administrator permission to appliation pool , so that your application could have access to folder where your python script is in.(It is not recommended because it gives too much permission to application pool)

    About how to change application pool's identity to local system, you could refer to https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities

    You could also add  permission of all the related folder to your application pool user.

    About application pool  and file system's permission  and how to change the permission, please refer to https://stackoverflow.com/questions/5437723/iis-apppoolidentity-and-file-system-write-access-permissions

    Best regards,

    Ackerly Xu

    Thursday, May 30, 2019 3:25 AM