Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are using a Windows 7 box as build server.

As part of our continuous integration process I would like to stop and start an IIS 7 website. I have tried doing this from the command line using appcmd:

appcmd start site "my website"

However, this only works if I start the console window by choosing "Run as Administrator", so it won't work out-of-the-box from NAnt etc.

How do I script appcmd to be run with elevated privileges (or am I going about this in the wrong way)?

Thank you.

share|improve this question
Simply using the task scheduler, if you wanted to do this based on an event that can be tracked, will allow you to execute a script with elevated privileges. – Sean C. Jan 30 '13 at 14:46

This is NOT an advisable approach at all, due to security concerns...

But, if you grant read permissions to the service that is executing the appcmd to the file applicationHost.config file located in the %windir%\system32\inetsrv\config directory, you you should be able to execute a .bat file with appcmd commands inside of it from CruiseControl (at least in my case).

I did this on a Windows Server 2008 Build Server.

share|improve this answer
Well, given "Build server" security concerns are minor. Sometimes you have to. I more wonder why a build server needs that - my build servers ONLY build, nothing else. – TomTom Aug 25 '12 at 7:23
Are you kidding? Build server security is incredibly important unless you like shipping bots. – Falcon Momot Jul 27 '14 at 20:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.