Tutorial :reset IIS remotely


I'm going to reset IIS through a batch file. Using iisreset utility, as the batch file will be used by others who may log in the domain without the administrator account of the target server. How can I make the batch script running with proper permission? Thanks in advance!

And I also don't want to prompt the user to type in username/password as the batch file will be called by other programs.


You could create a windows service (using .net WCF for example) that executes this command. Then the service can run using credentials with administrator access.

Your other programs can call this service remotely.


Problem 1: Resetting remotely from batch. I prefer sc.exe


sc \\webserver stop w3svc  sc \\webserver start w3svc  

SC is not as heavy as IISRESET. Actually, I prefer to use WMI to recycle application pools, but that is tricky to do through batch

Problem 2: Allow users who are not Administrators on the target server to reset IIS.

You are either going to have to grant these users (or their group) permissions to control the services or store credentials somewhere. To grant the minimum permissions, see this KB -- a lot of work.

If you don't grant those executing the batch permission to restart services, see Rusell's answer -- create a WCF service.


"iisreset computername" will reset the IIS server if they have admin rights on computername. While I'm not sure how to change the user account in a batch file, this could be a security issue as batch files (as I'm sure you are aware) are stored in plain text.

PS. This would probably be better on ServerFault

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »