Have a Non-Domain server admin creds, want to manipulate its services

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have been getting many examples of how to access services from a remote server in C#, and turn them on and off. Unfortunately, the examploes seem to all relate to impersonating a domain user with permissions prior to using the ServicesControlManager
class. My situation is MUCH simpler: I have the actual administrator login ID and password for this computer (I can Remote Desktop using these creds), and it is NOT on a domain, just a standalone computer on the network. Is there a simple way I can just
simply use these creds to start and stop the services on the remote server that is NOT on a domain?

For instance, to GET a list of processes running from this server, all I have to do is query a ManagementScope object attached to the servers IP address, with the ManagementScope ConnectionOptions object simply containing the admins ID and password. Voila,
a list of all processes on the server! Cant I do a similar thing with the ServicesControlManager object to manipulate the services? Right now, every way I try to use SCM to do this on a remote server, i get the dreaded "Cannot open Service Control Manager
on computer foo This operation may require other privileges" error. And I am totally unsure of how to use Microsofts Impersonate class, as it seems to require a domain to be specified, and I am trying to access a standalone server on my network (no domain).

Can anyone point me in the right direction to connect my SCM class to a non-domain server, for which I have the full administrative creds to log onto if necessary?

Thanks,
Brian S.

View the full article
 
Back
Top