Windows自带一个控制服务的命令-SC,下面用Terminal Service做个简单例子:
查询Terminal Service的配置
C:\Users\jackie.chen>sc qc termservice [SC] QueryServiceConfig SUCCESS
SERVICE_NAME: termservice           TYPE               : 20  WIN32_SHARE_PROCESS            START_TYPE         : 2   AUTO_START            ERROR_CONTROL      : 1   NORMAL            BINARY_PATH_NAME   : C:\Windows\System32\svchost.exe -k NetworkService            LOAD_ORDER_GROUP   :            TAG                : 0            DISPLAY_NAME       : Terminal Services            DEPENDENCIES       : RPCSS                               : TermDD            SERVICE_START_NAME : NT Authority\NetworkService
关闭Terminal Service服务
C:\Users\jackie.chen>sc stop termservice
SERVICE_NAME: termservice           TYPE               : 20  WIN32_SHARE_PROCESS            STATE              : 3  STOP_PENDING                                    (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)            WIN32_EXIT_CODE    : 0  (0x0)            SERVICE_EXIT_CODE  : 0  (0x0)            CHECKPOINT         : 0x1            WAIT_HINT          : 0xea60
查询Terminal Service服务
C:\Users\jackie.chen>sc query termservice
SERVICE_NAME: termservice           TYPE               : 20  WIN32_SHARE_PROCESS            STATE              : 1  STOPPED            WIN32_EXIT_CODE    : 0  (0x0)            SERVICE_EXIT_CODE  : 0  (0x0)            CHECKPOINT         : 0x0            WAIT_HINT          : 0x0
启动Terminal Service服务
C:\Users\jackie.chen>sc start termservice
SERVICE_NAME: termservice           TYPE               : 20  WIN32_SHARE_PROCESS            STATE              : 2  START_PENDING    (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)         WIN32_EXIT_CODE    : 0  (0x0)            SERVICE_EXIT_CODE  : 0  (0x0)            CHECKPOINT         : 0x0            WAIT_HINT          : 0x7d0            PID                : 1456            FLAGS              :
查询Terminal Service服务的显示名称
C:\Users\jackie.chen>sc getdisplayname termservice     [SC] GetServiceDisplayName SUCCESS    Name = Terminal Services
更多用法:
        sc <server> [command] [service name] <option1> <option2>...
        The option <server> has the form \\ServerName (用于控制远程机器上的Windows服务)           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 (persistent).              description-----Changes the description of a service.              failure---------Changes the actions taken by a service upon failure.              failureflag-----Changes the failure actions flag of a service.              sidtype---------Changes the service SID type of a service.              privs-----------Changes the required privileges 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.              qfailureflag----Queries the failure actions flag of a service.              qsidtype--------Queries the service SID type of a service.              qprivs----------Queries the required privileges 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 arbitrary 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

SC-控制Windows服务的命令的更多相关文章

  1. 玩转Windows服务系列——命令行管理Windows服务

    说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令,命令行都是非常方便以及强大的工具. 接下来就看一下如何通过cmd命 ...

  2. 玩转Windows服务系列——命令行管理Windows服务

    原文:玩转Windows服务系列——命令行管理Windows服务 说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令, ...

  3. [转]玩转Windows服务系列——命令行管理Windows服务

    本文转自:http://www.cnblogs.com/hbccdf/p/managewindowsservicewithcmd.html 说到Windows服务的管理就不得不说通过命令行的方式管理W ...

  4. C# ASP.NET 控制windows服务的 开启和关闭 以及重启

    用ASP.NET控制Windows服务的开启与关闭效果如图 代码 首页页面需要添加引用 页面的pageload中 实例化windows服务 protected void Page_Load(objec ...

  5. C#使用ServiceController控制windows服务

    C#在,使用ServiceController控制类windows服务,添加首次使用前引文:System.ServiceProcess,空间中引用:using System.ServiceProces ...

  6. Windows服务安装命令:

    sc create YY.SmsPlatform.RemoteDataCenter binPath= "E:\YY.SmsPlatform\YY.SmsPlatform.RemoteData ...

  7. Windows服务BAT命令-安装、卸载、启动、停止

    1.安装服务 %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe D:\WiseMES\MES.WindowsService ...

  8. 二种方法安装卸载Windows服务的命令

    第一种方法:通过Dos命令安装系统服务1. 开始 运行输入 cmd 进入dos窗口2. cd命令进入到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727目录下, ...

  9. 项目Windows服务安装命令:

    sc create YY.SmsPlatform.RemoteDataCenter binPath= "E:\YY.SmsPlatform\YY.SmsPlatform.RemoteData ...

随机推荐

  1. centos 6.X 安装scrapy-原创

    特别注意[坑]: python版本一定大于 2.7.5,scrapy python 必须2.7以上centos 6.X系列 系统默认安装的python是2.6.6 ,本人折腾了很久2.7.3 在这里升 ...

  2. 后台获取前台runat=server的select的值

    <li> <asp:Label ID="Lpro" runat="server" Text="省份:" CssClass= ...

  3. gogs安装

    1.下载gogs文件,如果图方便可以选择编译好的文件网址https://gogs.io/docs/installation/install_from_binary 2.gogs web运行gogs 3 ...

  4. 关于cocoa框架,你所要知道的一切(苹果官方文档,cocoa框架核心竞争力,必须收藏!)

    https://developer.apple.com/library/ios/documentation/General/Conceptual/DevPedia-CocoaCore/Accessib ...

  5. git项目版本管理

    一个很小的HTML项目,使用.Git来记录和跟踪这个项目.包括以下内容: 创建版本库. 添加与修改文件. 创建新分支. 打标签并整理版本库. 克隆版本库. 创建版本库 Creating a Repos ...

  6. Solr搜索基础

    本例我们使用类库和代码均来自: http://www.cnblogs.com/TerryLiang/archive/2011/04/17/2018962.html 使用C#来模拟搜索.索引建立.删除. ...

  7. <q>标签,短文本引用;<blockquote>标签,长文本引用

    <q>标签,短文本引用 <q>引用文本</q>,默认显示双引号,不需要在文本中添加 <blockquote>标签,长文本引用 浏览器对<block ...

  8. 【Algorithm】堆排,C++实现

    对一个数组中的元素按照顺序构建二叉树,就形成了一个(二叉)堆.(二叉树是虚拟的,并不是真的建立二叉树) 表示堆的数组A有两个重要属性:A.heapSize,表示堆里面有多少元素,数组里有多少元素在堆里 ...

  9. iOS FMDB小试了一下

    今天从早上9点,一直在看FMDB,知道中午11:40.我的效率是不是很低下.中间也碰到了几个小bug. 虽然做了一个小demo,但是觉得还比不上在项目中使用中锻炼的多,先暂且一总结. 先下载FMDB的 ...

  10. Java学习-011-创建文件实例及源代码

    此文源码主要为应用 Java 创建文件的源代码.若有不足之处,敬请大神指正,不胜感激! 创建文件的源代码如下所示: /** * @function 文件操作:创建文件.若文件不存在,则直接创建文件:若 ...