Re: Kill remote Process(service)



Did you allow your service to interact with desktop ( through services admin
tool ) , just a hint ?
Arkady

"Anton" <akhodakivskiy@xxxxxxxxx> wrote in message
news:1155051207.842862.223630@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Here is my code:

schSCManager = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
if (schSCManager == NULL)
return RS_RESULT_OPEN_SC_MANAGER_ERROR;

schService = OpenService( schSCManager, _T("RemoteRegistry"),
SERVICE_ALL_ACCESS); //Create Service Handle
if (schService == NULL)
return RS_RESULT_OPEN_SERVICE_ERROR;

if (!QueryServiceStatusEx( schService, SC_STATUS_PROCESS_INFO,
(LPBYTE)&ssStatus,
sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded ) ) //Get
Current Service State
return RS_RESULT_QUERY_SERVICE_STATUS_ERROR;

hProcess = OpenProcess(PROCESS_TERMINATE, FALSE,
ssStatus.dwProcessId);
if (hProcess = NULL)
return RS_RESULT_OPEN_PROCESS_ERROR;

if (TerminateProcess(hProcess, 0) == 0)
return RS_RESULT_TERMINATE_PROCESS_ERROR;

Anton wrote:
Thank you for your help and support

Ok.. I wrote s simple service which tries to kill some process with
TerminateProcess WINAPI.
But I am getting error ERROR_INVALID_HANDLE ? 6.
I think the reason of that error is that im trying to kill the process
from windows service.
Any ideas, how to avoid this?
How pskill.exe's service deals with this?

Thanks
Anton


.



Relevant Pages

  • Re: Kill remote Process(service)
    ... if (!QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, ... Current Service State ... hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, ... I think the reason of that error is that im trying to kill the process ...
    (microsoft.public.win32.programmer.networks)
  • Privileges and killing a process
    ... then the application will kill them (by terminating the process by PID). ... Dim hProcess As Long ... GoTo CleanUp ...
    (microsoft.public.vb.general.discussion)
  • Re: Privileges and killing a process
    ... then the application will kill them (by terminating the process by PID). ... >Dim hProcess As Long ... >GoTo CleanUp ...
    (microsoft.public.vb.general.discussion)
  • Re: Privileges and killing a process
    ... "Lee Peedin" wrote: ... sure seems like a lot of code when you can run a simple script ... then the application will kill them. ... >>Dim hProcess As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: how to set PROCESS_TERMINATE privilege?
    ... You can kill any process you started, either by hand or with any other ... You only need privileges if you want to kill a process that does not ... TerminateProcess(hProcess, 0) ... // change this in production code ...
    (borland.public.delphi.nativeapi)

Quantcast