Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Windows Services Programmatically

Status
Not open for further replies.

topcat01

Programmer
Jul 10, 2003
83
GB
Hi,

Does anybody know if it is possible to disable the Windows Desktop Search service programmatically using Delphi?

This is a service on a Vista machine.

If fact is it possible to disable any service?

Thanks
 
Yes, it certainly used to be (not sure about Vista).

Quick and dirty:

winexec(pchar('net stop spooler'), SW_SHOW);

Substitute "spooler" for the name of the service.

Paul Rigby
VBA, C#, Delphi
 
Sure. Call the service controller command-line interface using CreateProcess or ShellExecute

To disable the BITS service
Code:
sc config "BITS" start= disabled

To enable the BITS service to automatic
Code:
sc config "BITS" start= auto

To enable the BITS service as manual
Code:
sc config "BITS" start= demand

Look at the Adminstrative services panel under the properties for the service you're interested in to find out the proper name.

Measurement is not management.
 
or the correct way, using the servicemanager:


there are components out there that allow even better control (like NTSet) but they also use the servicemanager.

One thing you need to be sure of is that the user has enough rights to start/stop services.

Cheers,
Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks guys that's more than enough to get me started.

Have a good weekend.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top