Foo.cmd won’t output lines in process (on website)

I found the answer myself and will post a solution for anyone interested.

The source of the issue is fairly hard to debug, because the problem originated in how IIS handles users and processes.

As I thought, there was nothing wrong with the code itself.

Answer

In IIS, a website is running in a AppPool. An AppPool is assigned an user identity. The default identity is a virtual built-in account named ApplicationPoolIdentity. This user does not have the privilege to call any (as far as I know) external batch/command scripts.

Providing a username, password and domain for a administrative user when starting a new process, didn’t solve anything for me – It might be that I’m just misunderstanding the whole concept.

Using <identity impersonate="true" userName="domain\user" password="pass" /> in the webconfig didn’t solve anything either. This is apparently because the assigned AppPool user is still the author of all processes.

What really bugged me out, was that I could execute .exe files, but not .cmd or .bat files.

The solution for me, was to create a new user with privileges to execute batch scripts and select that user as the AppPool user in IIS.

Edit: As I have mentioned in the comments, the user I’m working with is created on an Active Directory server as this particular file server is on a network share. The user is part of the local server group IIS_IUSRS on my webserver and has read/write/execute privileges in the folder where the executable programs are stored.

Edit2: The solution works for local user accounts as well as long as the user is part of the local server group IIS_IUSRS and has read/write/execute privileges in the folder where the executable programs are stored.

Leave a Comment