Create/delete/start/stop a service from command-line

For some reason, I just needed to do something like this, so here is a quick how-to:

There is a tool named sc.exe in the Win 2K Resource Kit, however I believe it also exists in Windows XP, as I did not have to do anything, and was able to access it from command-line.

Using this tool, you can see the list of the services that are currently running, add, delete, create or stop services.

The syntax for creating a service is like this:

sc create [service name] [binPath= ]

What this command does is basically the same as the CreateService API function.

Similarly, the commands to achieve other purposes are:

sc delete

sc start

sc stop

For more information you can have a look at here.

You can also view services existing on the system or even delete them from this registry key :

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

Oh, and by the way, if; for some reason you need to get ahold of Windows 2000 Resource Kit Tools, you can get them here.

Post a Comment