Archimedes
August 3rd, 2005, 11:04 AM
I need some help understanding and implementing Service Controller Permissions. The problem I have is, I have a service running, and want to connect to it remotely with a service controller. I can get browse permission for it - i.e. can tell whether or not its running - but do not get control permission. I read MSDN about ServiceControllerPermission class, but it left me more confused. I am not sure how to use it (if I need to) in conjunction with the ServiceController. I created a new ServiceControllerPermission object and used Assert which didn't fail, but I still dont get control!? Incidentally I have Administrative access on both the home and target machine, we're on a domain of which I am a Domain Administrator, and of course it all works fine when I try to control the service on my own machine. There was a lot about Assembly signing, etc., is this a problem of the calling program, the service.... ?
ServiceControllerPermission *SPE = new ServiceControllerPermission( ServiceControllerPermissionAccess::Control, ComputerName, "EMPIWinService" );
try
{
SPE->Assert();
ServiceController *empiController = new ServiceController("EMPIWinService", ComputerName);
if (!(empiController->get_CanStop()) && (empiController->Status == (ServiceControllerStatus::Stopped)) )
{
...
empiController->Start(); <-- throws exception here
...
Any help is appreciated
ServiceControllerPermission *SPE = new ServiceControllerPermission( ServiceControllerPermissionAccess::Control, ComputerName, "EMPIWinService" );
try
{
SPE->Assert();
ServiceController *empiController = new ServiceController("EMPIWinService", ComputerName);
if (!(empiController->get_CanStop()) && (empiController->Status == (ServiceControllerStatus::Stopped)) )
{
...
empiController->Start(); <-- throws exception here
...
Any help is appreciated