I have a website created by C# which is to start a services in a server.
I created a services called MyService
using this :
instsrv MyService %systemroot%\system32\srvany.exe
then I uses the following code to call it :
ServiceController service = new ServiceController("MyService");
try
{
service.Start();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
but when I access the website and trigger this event, it prompt me
Cannot open <MyService> service on computer '.'
Is it because of the security or permission problem?? Any guide with clear steps is highly appreciated.
hi i had the same prob been giving permission to all group that i thought of include the cleaners and it didnt help finally i tried this line in my web config
i have actually solve the problem of on top scenario.
These is what needed in the IIS and services.msc
In the other hand, there will still be error about the MAC address.
So, we need a which can be generate by machineKey Generator.
The machineKey generated is needed to paste at the tag below.
Then copy the whole block of quote below and paste it to the
Web.config
And the problem will then be solve, maybe the situation you guys faced may be different but i hope it may help someone as i struggle in this quite a long time.
In addition, i uses this code so there will no conflict when start and stop the services created.
Good Luck and thanks you guys for helping.
ref: http://www.csharp-examples.net/restart-windows-service/
http://forums.asp.net/t/906759.aspx/3/10
with iis (version 6 and higher), web apps are run using an application pool. EAch application pool can run with a specific user (the identity), which is, by default, NETWORK SERVICE. It's a very bad idea to add this user to local administrators.
Possible ways :
It might help someone with a related issue:
On my server, a powershell commandlet was failing with the same error message. It was because, even if I was logged as the local admin, I needed to run the PowerShell environment as an administrator (right click, run as Administrator).