service controller

G

Guest

Hello everyone,

I have this application that stops and starts IIS admin. When I try to
stop the service. I get an error "Cannot open IISADMIN service on computer
'.'.". I tried changing the machine name to my machine name then also it does
not work.


Below is the code
ServiceController controller = new ServiceController();
//controller.MachineName = "CS1239876";
controller.MachineName=".";
controller.ServiceName = "IISADMIN";
string status = controller.Status.ToString();
if(status == "Running)
controller.Stop();

Can anyone please help me with this.

Any help will be appreciated.
 
M

Michael Nemtsev

Hello vinki,

The error says that It cant find the service with such name
try controller.ServiceName = "World Wide Web Publishing Service"

---
WBR, Michael Nemtsev [C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

v> Hello everyone,
v>
v> I have this application that stops and starts IIS admin. When I try
v> to stop the service. I get an error "Cannot open IISADMIN service on
v> computer '.'.". I tried changing the machine name to my machine name
v> then also it does not work.
v>
v> Below is the code
v> ServiceController controller = new ServiceController();
v> //controller.MachineName = "CS1239876";
v> controller.MachineName=".";
v> controller.ServiceName = "IISADMIN";
v> string status = controller.Status.ToString();
v> if(status == "Running)
v> controller.Stop();
v> Can anyone please help me with this.
v>
v> Any help will be appreciated.
v>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top