日省其身,有则改之,无则加勉!
当前位置:首页系统技巧 - SC命令学习

SC命令学习

    以普通PC用户来说,现在在XP或是高级的版本当中用SC更改系统服务状态是非常少了.一般都是在系统管理里面进行图形化操作了,但是对于维护电脑人员来说,这个命令还是很有用处的.不管是删除已被发现的木马插入式服务还是在纯DOS环境下修改系统服务的参数和状态,都实分有用.另外,万一遇到系统故障或是病毒入侵,没办法打开服务services.msc,用这个SC命令也是一个不错的方法.

㈠、关于 SC 命令。

  简单介绍一下 SC 命令:SC:与“服务控制器”和已安装设备通讯。SC.exe 检索和设置有关服务的控制信息。可以使用 SC.exe 来测试和调试服务程序。可以设置存储在注册表中的服务属性来控制如何在启动时和作为后台程序运行时启动服务应用程序。SC.exe 的参数可以配置指定的服务,检索当前服务的状态,也可以停止和启动服务。可以生成批处理文件来调用不同的 SC.exe 命令以自动启动或关闭服务序列。SC.exe 提供的功能类似于“控制面板”中“管理工具”项中的“服务”。
 
㈡、设置服务的启动类型。

  SC 命令的用法比较复杂,这里介绍 sc config :修改注册表和“服务控制管理器”数据库中的服务项的值。

语法:
Modifies a service entry in the registry and Service Database.
SYNTAX:
sc <server> config [service name] <option1> <option2>...
CONFIG OPTIONS:
NOTE: The option name includes the equal sign.
 type= <own|share|interact|kernel|filesys|rec|adapt>
 start= <boot|system|auto|demand|disabled>
 error= <normal|severe|critical|ignore>
 binPath= <BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <Dependencies(separated by / (forward slash))>
 obj= <AccountName|ObjectName>
 DisplayName= <display name>
 password= <password>

  但就设置本地计算机的服务启动类型,语法还可以简单一点:

语法:sc config messenger start= {boot | system | auto | demand | disabled}

  其中,messenger 为服务名, start= 后面为启动的类型。例如,我们要设置Windows Image Acquisition (WIA)服务(为扫描仪和照相机提供图像捕获)为手动,则 Windows Image Acquisition (WIA)服务的服务名为“stisvc”,手动的参数值为“demand”,那么,这个命令就是:

sc config stisvc start= demand
 
  说明:参数和值之间必须有空格,例如“start= demand”。

start= 启动类型:
start= {boot | system | auto | demand | disabled}

boot:由启动加载程序加载的设备驱动程序。
system:在核心初始化过程中启动的设备驱动程序。
auto:(自动)每次计算机重新启动时都会自动启动、并且即使无人登录到计算机也能正常运行的服务。
demand:(手动)必须手动启动的服务。如果没有指定 start=,则此项即为默认值。
disabled:(已禁用)不能启动的服务。要启动禁用的服务,应将启动类型更改为其他值。


对于SC的其他用法在系统里面还有如下功能:
DESCRIPTION:
        SC is a command line program used for communicating with the
        NT Service Controller and services.
USAGE:
        sc <server> [command] [service name] <option1> <option2>...

        The option <server> has the form "\\ServerName"
        Further help on commands can be obtained by typing: "sc [command]"
        Commands:
          query-----------Queries the status for a service, or
                          enumerates the status for types of services.
          queryex---------Queries the extended status for a service, or
                          enumerates the status for types of services.
          start-----------Starts a service.
          pause-----------Sends a PAUSE control request to a service.
          interrogate-----Sends an INTERROGATE control request to a service.
          continue--------Sends a CONTINUE control request to a service.
          stop------------Sends a STOP request to a service.
          config----------Changes the configuration of a service (persistant).
          description-----Changes the description of a service.
          failure---------Changes the actions taken by a service upon failure.
          sidtype---------Changes the service SID type of a service.
          qc--------------Queries the configuration information for a service.
          qdescription----Queries the description for a service.
          qfailure--------Queries the actions taken by a service upon failure.
          qsidtype--------Queries the service SID type of a service.
          delete----------Deletes a service (from the registry).
          create----------Creates a service. (adds it to the registry).
          control---------Sends a control to a service.
          sdshow----------Displays a service's security descriptor.
          sdset-----------Sets a service's security descriptor.
          showsid---------Displays the service SID string corresponding to an ar
bitrary name.
          GetDisplayName--Gets the DisplayName for a service.
          GetKeyName------Gets the ServiceKeyName for a service.
          EnumDepend------Enumerates Service Dependencies.

        The following commands don't require a service name:
        sc <server> <command> <option>
          boot------------(ok | bad) Indicates whether the last boot should
                          be saved as the last-known-good boot configuration
          Lock------------Locks the Service Database
          QueryLock-------Queries the LockStatus for the SCManager Database


分享到: 更多

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。