Question

I am using ServerManager within Microsoft.Web.Administration to read and operate on IIS sites. This unfortunately seems to require UAC, is there a way around this or do I just have to accept that I will have to ask my user for permission before doing this?

var server = new ServerManager();
var site = server.Sites.FirstOrDefault(s => s.Name == "websiteName");
site.Stop();
Was it helpful?

Solution

You could do 2 things, if your program is Autonomous, you can set is up a a scheduled task and set it to run as "SYSTEM"

or, if you need to be able to interact with the application you could build a console application that actually does all the work, run that application all the time starting it like above as a scheduled task running as system.

That can be called MyAppService (although you dont have to build a server application, console app is fine)

Then, build an app that has all the button various functions you'd like to do and have it request the work to be done by the MyAppService. This second application can be run as a standard user because all the elevated work is done by the service.

I've done it before through Named Pipes and it worked a treat.

I hope that makes sense!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top