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. jquery 选择器,模糊匹配

    按姓名匹配 1,name前缀为aa的所有div的jquery对象 $("div[name^='aa']"); 2,name后缀为aa的所有div的jquery对象 $(" ...

  2. visual studio 2005 编fortran程序,运行后dos窗口显示问题

    比如程序: program main implicit none write(*,*) "AAAAAAAAAAAAAAAAAAAAAAAA" stop end 虽然可以看见DOS窗 ...

  3. delphi 高版本可执行程序减小的办法

    选菜单里的 Project -> Options.. (Shift+Ctrl+F11)出现Project Options for Project1.exe窗口,在左边选 Packages出现如下 ...

  4. hadoop编程模型

    1. 拷贝数据 将一个超大的数据文件拷贝到hadoop集群中,hdfs将其分割成多个数据块,然后再把每一个数据块放到不同的节点里面. 2. map函数 提交一个map函数,此map函数可以被jobch ...

  5. 深入了解php opcode缓存原理

    什么是opcode opcode(operate code)是计算机指令中的一部分,用于指定要执行的操作,指令的格式和规范由处理器的指定规范指定 opcode是一种php脚本编译后的中间语言,就像ja ...

  6. Redis学习二 C#中如何进行这五种数据类型的操作

    我在网上找了好久,就是没有找到Redis和C#结合的书,都是和别的编程语言在一起鬼混. 简单的用C#实现向Redis中插入那我中类型的数据 首先需要到NuGet 里面下载 Redis IDatabas ...

  7. C# DateTime类型和时间戳 互相转换

    /// <summary> /// 时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></para ...

  8. ACCESS自动编号重新从1开始

    方法一:  删掉自动编号的字段,再建一个同样的自动编号字段. 方法二:  选择工具,再选择数据库实用工具,单击压缩和修复数据库,这样就OK了. 方法三:(提示错误“无效的数据字段类型” 尝试失败)  ...

  9. iOS 增加UIButton按钮的可点击区域

    在很多时候,按钮可能看起来那么大,但是在它周围进行点击时,都能够触发事件,是因为它的可点击区域比我们看到的button要大. 在使用AutoLayout的时候,我们处理的是按钮的image属性,所以这 ...

  10. android studio配置AndroidAnnotations

    现在很多人都使用Android studio开发工具代替eclipse了,当然的 在eclipse使用的好的一些开发框架也会对应的在android studio上面使用. 参考文档:http://bl ...