SC command to communicate with the service controller and installed devices. SC .exe retrieves and sets service control information. You can use SC .exe to test and debug the service.Program. You can set service properties stored in the registry to control how to start the service application at startup and how to run the application as a background program. The SC .exe parameter can be used to configure the specified service, retrieve the current service status, or stop and start the service. You can create a batch file to call different SC .exe commands to automatically start or stop the service sequence. SC .exe provides functions similar to "services" in "Administrative Tools" in "Control Panel ".
Common commands:
View service information: SC Query [servicename]
Create a service: SC create [service name] [Bin path]
Change service configuration: SC config [service name]
Delete service: SC Delete [service name]
Ex. [Code] create a service:
SC create svnservice binpath = "D: \ subversion \ bin \ svnserver-service" displayname = "svnservice" depend = TCPIP
Set to self-start
SC config svnservice start = auto
Start SC start svnservice
Or Net start svnservice
[/Code]
For more help, you can view the Command help or Google it at runtime.
Note: To use the SC command, you need to install the window 2000/2003 Resource Kit toolkit. You can add or delete Windows components to install it.
Example: SC CREATE command line to add/create/modify a service
Add service:
SC create bits binpath = "C: \ windows \ system32 \ svchost.exe-K netsvcs" type = share start = auto displayname = "Background Intelligent Transfer Service" depend = RPCSS/EventSystem
Description:
SC description bits "transmits files in the background using idle network bandwidth. If the service is disabled, such as Windows Update and MSN Explorer, programs and other information cannot be automatically downloaded. If this service is disabled, any service dependent on it may not be able to transmit files directly through ie without fault tolerance. Once bits is disabled, files may not be transmitted. "
Add service:
SC create PolicyAgent binpath = "C: \ windows \ system32 \ lsass.exe" type = share start = auto displayname = "IPSec Services" depend = RPCSS/TCPIP/IPSec
Description:
SC description yyagent "provides client-to-server security on TCP/IP networks. If the service is disabled, the TCP/IP security between the client and the server on the network is unstable. If this service is disabled, any service dependent on it cannot be started. "
For more information about SC commands, see help SC
(Back up the registry before modification ),
special feature of the svchost shared service: you may need to go to the Registry location after restart: [HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ svchost] To View "C: \ windows \ system32 \ svchost.exe-K netsvcs "is a key named in red (here, netsvcs is used as an example ), whether the service with SC create bits blue characters is defined in the key value (Here we use bits as an example). If not, add the service name (Here we use bits as an example) in the key value, restart again.