Re: How to remote start/stop services using windows API?



Thanks Kellie.
Before we call OpenSCManager, we must obtain an remote user
handle/credential. Otherwise OpenSCManager will fail with error: "access
deny...".
WNetAddConnetion2 could be used to get the remote user credential, but it
will fail in some cases. So I am searching another way to do it. Thanks.

--
Tom Lee


"Kellie Fitton" wrote:

On Nov 7, 7:26 am, Tom Lee <Tom....@xxxxxxxxxxxxxxxx> wrote:
I tried to use WNetAddConnection2 and OpenSCManager.
But WNetAddConnection2 will fail if there are a existing remote mapped drive
to the remote manchine. It seems WNetAddConnection2 has other limitations.

Any comments are appreciated. Thanks in advance.
--
Tom Lee


Hi,

You can use the following APIs to start a service process remotely:

OpenSCManager()

GetServiceKeyName()

OpenService()

QueryServiceStatusEx()

ControlServiceEx()

StartService()

CloseServiceHandle()

http://msdn2.microsoft.com/en-us/library/ms684323.aspx

http://msdn2.microsoft.com/en-us/library/ms683229.aspx

http://msdn2.microsoft.com/en-us/library/ms684330.aspx

http://msdn2.microsoft.com/en-us/library/ms684941.aspx

http://msdn2.microsoft.com/en-us/library/ms682110.aspx

http://msdn2.microsoft.com/en-us/library/ms686321.aspx

http://msdn2.microsoft.com/en-us/library/ms682028.aspx

http://support.microsoft.com/?kbid=179249

http://support.microsoft.com/kb/q180116/

Kellie.



.



Relevant Pages