IIS wont run a BAT File

asp.netbatch-fileiisiis-7

The problem we have run into is as follows. We have an ASP.NET WebService which runs under IIS7. The code in the WebService works 100%, however when the WebService tries to run a .BAT file, nothing happens. Nothing at all, the code doesn't crash, the server doesn't warn us about anything, nothing at all.

We have tried setting the User Permissions, we have attempted difference ways of running the BAT, we have tried playing around with the registry, cmd.exe has full rights as well.

We are now quite stumped as of what to do, any help would be appreciated.

Best Answer

(Note: The old answer was sort of correct, sort of not correct. Out of box, IIS can't execute cmd.exe instances, but it apparently is possible ... )

You can run batch files from within IIS, via ASP.NET, but it requires your impersonation settings to be 100% spot on.

I'm going to assume, for purposes of this post, that you are in a very secure environment and you've already considered all the potential attack vectors that could be opened by allowing IIS to execute batch files (which are in instances of cmd.exe.)

So the web process needs to be running as either Administrator (GAH!) or another account which can execute the batch process. I believe this will not be possible with the in-box ASPNET/IUSR_ accounts.

Activate impersonation is described here on MSDN, and give it a day in court.

Related Topic