1. Description:sc is a command line program used to communicate with the service control manager.
sc<server>[command] [service name]<option1><option2>...
The format of option<server>is
You can type "sc [command]" for further help with the command
query --------------- Query the status of the service,Or enumerate the status of a service type. queryex ------------ Query the extended status of the service, Or enumerate the status of a service type. start ---------------- Start the service. pause -------------- Send a pause control request to the service. interrogate -------- Sends interrogate control requests to the service. continue ----------- Send a continue control request to the service. stop ---------------- Send a stop request to the service. config -------------- (permanently) change the configuration of the service. description -------- Change the description of the service. failure -------------- Change what happens when the service fails. qc ------------------- Query service configuration information. qdescription ------- Query the description of the service. qfailure ------------- Query operations performed by the failed service. delete --------------- (from the registry) delete the service. create --------------- Create a service (add it to the registry). control -------------- Sends control to the service. sdshow -------------- Displays the security descriptor of the service. sdset ---------------- Set the security descriptor of the service. getdisplayname --- Get the displayname of the service. getkeyname -------- Get the servicekeyname of the service. enumdepend ------- enumerate the dependencies of the service.
The following commands do not query the service name:
sc<server><command><option> boot --------------- (ok | bad) indicates whether to save the last boot as the last known good boot configuration lock --------------- Lock the service database querylock ------- Query the lockstatus of the scmanager database
Type sc in the command line window that appears
Use sc /?command to query other functions
Example 1:Registering a service (something like autoloading on system startup in Linux)
sc create ilmservice binpath="c:/program files/subversion/bin/ilmservice.exe --service -r d:/svn" displayname="ilmmainservice" depend=tcpip start=auto
Add service description:sc description "ilmservice" "Identity Management Platform Service Program"
Where sc create is the sc registration service command
svn:is the key name when the service is registeredbinpath:is the path and command parameters of the service loader startup filedisplayname:is the service display namedepend:the protocol on which the transport dependsstart:whether to start automatically
Note:The above example is registering an svn service
Example 2:start service
sc start myservice
Example 3:delete service
sc delete [servicename]
For example, to delete the apache2.2 service, the operation is as follows:sc delete apache2.2
Added:If the service cannot be deleted with the sc command,Can be deleted from the registry.
reg delete hklm/system/currentcontrolset/services/servicename
windows registration service command sc usage
1. The difference between the service display name and the registration key,The display name is mainly the name displayed outside (such as the subversion server). You can use the commands msconfig and service.msc to view it.
Key name, another method is to use hkey_local_machine->system->service in the regedit registry to view.
Key and display name conversions:
sc getkeyname (display name) ---->get the key name from the display name
sc getdisplayname (key name) ---->get display name from key name
2. The operation of the service must be done by the key name,Display name does not work
3. After getting the key name, you can operate the service like the linux command service
Service start sc start "key name" For example:sc start svn
Service stop sc stop "key name" For example:sc stop svn
Service delete sc delete "key name" For example:sc delete svn
For the SC command, Windows is not commonly used, but the service command is often used under Linux. In fact, these two commands are the same.Example of registering under windows through svn
to sum up
- linux - conditions under which the command expansion of ls * (asterisk) is executed
- Summary of precautions for using the kill command in Java applications
- MySQL ALTER command knowledge summary
- Summary of MongoDB Shell Command Examples [Advanced]
- Linux cut command usage summary
- Summary of java command calling virtual machine methods
- Command to view the creation time of the binlog file under Linux
- Detailed 7 SSH command usage you don't know under Linux
- Linux view the summary of the command methods used
- A summary of regular expression grep under linux
- Mkfsvfat command for porting busybox under Linux system
- Summary of Linux sftp command usage
- Linux vi command knowledge summary
- Summary of new usage of vi (vim) under linux
- Summary of basic mongodb command examples
- PowerShell Command Operations Collection (Summary)
- Summary of command and operator knowledge in easy language
- Linux nc command summary