I use a routine that can start and stop services via Delphi but I also need to be able to disable them, is it possible?
This is what i use
It's just a little wrapper around some Windows API Functions we found useful to handle NT-Services. It allows you to query, start, stop, pause and enable/disable NT-Services on the local or a remote system.
http://blog.marcduerst.com/post/How-to-use-TServiceManager-to-manage-Windows-services.aspx
Which lets you write 'nice' delphi code ;)
procedure DisableService(ServiceName: PChar);
var SM: TServiceManager;
begin
SM:=TServiceManager.Create;
try
SM.Connect;
SM.OpenServiceConnection(ServiceName);
//not working with TServiceManager as is
//but its easy to fix, see below
SM.DisableService;
finally
SM.Free;
end;
end;
the DisableService section hasnt been written, but all that is needed is
procedure TServiceManager.DisableService;
begin
ChangeServiceConfig(ServiceHandle, SERVICE_NO_CHANGE,SERVICE_DISABLED,SERVICE_NO_CHANGE, nil, nil, nil, nil, nil, nil, nil);
end;