views:

29

answers:

2

Hello,

How could I do this with no access denied problem?

I have a windows service:

protected override void OnCustomCommand(int command)
{

    if (command == 1)
    {
      foreach (Process traceProcess in Process.GetProcessesByName("notepad.exe"))
      {
        traceProcess.Kill();
      }                     
    }

}

when I do this:

ServiceController sc = new ServiceController("ProjectManager");

if (sc != null)
    sc.ExecuteCommand(1);

From a windows forms it works, but not from a web page, I get access denied on sc.ExecuteCommand.

What's the best way for a web page to talk to a service?

A: 

You need to check the permissions of the the application pool identity.

ChaosPandion
A: 

Hello,

I got a workaround for the permission problem; sockets.

So my service opens a local port (not available to any other machine, only local)

Then in my web page I connect to this socket and send the byte I want, and in return the service executes the code I want.

If anyone asks, I can post example code.

Enriquev