Windows Service的官方描述,抄下来(不写obj就是LocalSystem)
How to create a Windows service by using Sc.exe
Support for Windows XP has ended
Microsoft ended support for Windows XP on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.
Support for Windows Server 2003 ended on July 14, 2015
Microsoft ended support for Windows Server 2003 on July 14, 2015. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.
SUMMARY
To remotely create and start a service from the command line, you can use the SC tool (Sc.exe) included in the Resource Kit.
Although you can use the Netsvc.exe and Instsrv.exe tools to start a service on a remote computer, these tools do not give you the ability to remotely create a service.
Note The Srvinstw.exe tool is the graphical user interface (GUI) version used to create remote services. Srvinstw.exe is not a command-line tool.
MORE INFORMATION
You can use Sc.exe to help develop services for Windows. Sc.exe, which is provided in the Resource Kit, implements calls to all of the Windows service control application programming interface (API) functions. You can set the parameters to these functions by specifying them on the command line. Sc.exe also displays service status and retrieves the values stored in the status structure fields. The tool also lets you specify the name of a remote computer so that you can call the service API functions or view the service status structures on the remote computer.
Sc.exe also allows you to call any of the service control API functions and vary any of the parameters from the command line. The advantage to this is that it provides a convenient way to create or configure the service information in the registry and the Service Control Manager database. You do not have to configure the service by manually creating entries in the registry and then restarting the computer to force the Service Control Manager to update its database.
Sc.exe uses the following syntax:
Syntax1 (use Syntax1 to run Sc.exe)
Syntax2 (use Syntax2 to display help information, except for the query command)
Parameters
- Servername
Optional. Specifies the name of the server when you want to run the commands on a remote computer. The name must start with two backslash (\) characters (for example, \\myserver). To run Sc.exe on the local computer, do not supply this parameter. - Command
Specifies the sc command. Note that many of the sc commands require administrative privileges on the specified computer. Sc.exe supports the following commands:Config
Changes the configuration of a service (persistent).Continue
Sends a Continue control request to a service.Control
Sends a control to a service.Create
Creates a service (adds it to the registry).Delete
Deletes a service (from the registry).EnumDepend
Enumerates service dependencies.GetDisplayName
Obtains the DisplayName for a service.GetKeyName
Obtains the ServiceKeyName for a service.Interrogate
Sends an Interrogate control request to a service.Pause
Sends a Pause control request to a service.qc
Queries configuration for the service. For detailed information, see the reference section, "SC QC."Query
Queries the status for a service, or enumerates the status for types of services. For detailed information, see the reference section, "SC QUERY."Start
Starts a serviceStop
Sends a Stop request to a service. - Servicename
Specifies the name given to the Service key in the registry. Note that this is different from the display name (which is what you see with net start command and the Services tool in Control Panel. Sc.exe uses the service key name as the primary identifier for the service. - Optionname
The Optionname and Optionvalue parameters allow you to specify the names and values of optional command parameters. Note that there is no space between the Optionname and the equal sign. You can supply none, one, or more optional parameters name and value pairs. - Optionvalue
Specifies the value for the parameter named by Optionname. The range of valid values is often restricted for each Optionname. For a list of available values, request help for each command.
Many of the commands require Administrator privileges. Make sure that you are an administrator of the computer where the development is being performed.
The sc create command creates an entry for the service in the registry and in the Service Control Manager database.
Syntax
Parameters
- Servername
Optional. Specifies the name of the server when you want to run the commands on a remote computer. The name must start with two backslash characters (for example, \\myserver). To run SC on the local computer, do not supply this parameter. - Servicename
Specifies the name given to the service key in the registry. Note that this is different from the display name, which is what you see with net start and the Services tool in Control Panel. Sc.exe uses the service key name as the primary identifier for the service. - Optionname
The Optionname and Optionvalue parameters allow you to specify the names and values of optional parameters. Note that there is no space between the Optionname and the equal sign. You can supply none, one, or more optional parameters name and value pairs. The sc query command supports the following values:OptionnameOptionvaluetype=own, share, interact, kernel, filesys
Type of service you want to create. Optionvalues include types used by drivers.
(default = share)start=boot, system, auto, demand, disabled
Start type for the service. Option values include types used by drivers.
(default = demand)error=normal, severe, critical, ignore
Severity of error if the service does not start during boot.
(default = normal)binPath=(string)
Path name to the service binary file. There is no default for this parameter. This string must be supplied.group=(string)
Name of group which this service is a member of. The list of groups are stored in the registry under ServiceGroupOrder.
(default = nothing)tag=(string)
If this string is set to "yes," Sc.exe obtains a TagId from the CreateService call, however, Sc.exe does not display the tag.
(default = nothing)depend=(space separated string)
Names of services or groups that must start before this service.obj=(string)
Name of account in which the service runs. For drivers, this is the Windows driver object name.
(default = LocalSystem)DisplayName=(string)
A string that can be used by user-interface programs to identify the service.password=(string)
A password string. This is required if an account other than LocalSystem is used.
Optionvalue
Specifies the value for the parameter named by Optionname. See the Optionname reference for a list of supported values. When a string is to be input, the use of empty quotes means that an empty string is passed in. Note that there is a space between OptionValue and the equal sign.
Note The sc create command performs the operations of the CreateService API function.
The following example creates a registry entry for the service named "NewService" on the computer called \\remotecomputer:
Note In Windows 2000, Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008, the binpath is located at C:\Windows\System32\Newserv.exe.
This service is created as a WIN32_SHARE_PROCESS with a SERVICE_DEMAND_START start-type by default. It does not have any dependencies, and runs in the LocalSystem security context.
The following example creates the service on the local computer as an auto-start service that runs in its own process. It has dependencies on the TDI group and on the NetBIOS service. Notice that you must add quotes around the list of space-separated dependencies.
Note In Windows 2000, Windows XP, Windows Server 2003, Windows Vista, and Windows Server 2008, the binpath is located at C:\Windows\System32\Newserv.exe.
For further details about the Sc.exe tool, please see the Sc-dev.txt document in the Resource Kit. This document describes Sc.exe in greater detail.
Article ID: 251192 - Last Review: 09/11/2011 06:54:00 - Revision: 6.0
- Microsoft Windows NT Server 3.51
- Microsoft Windows NT Server 4.0 Standard Edition
- Microsoft Windows 2000 Server
- Microsoft Windows 2000 Advanced Server
- Microsoft Windows 2000 Professional Edition
- Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
- Microsoft Windows Server 2003, Datacenter Edition for Itanium-Based Systems
- Microsoft Windows Server 2003, Datacenter x64 Edition
- Microsoft Windows Server 2003, Enterprise x64 Edition
- Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
- Microsoft Windows Server 2003, Enterprise Edition for Itanium-based Systems
- Microsoft Windows Server 2003, Standard x64 Edition
- Microsoft Windows Server 2003, Standard Edition (32-bit x86)
- Windows Vista Home Basic
- Windows Vista Home Basic N
- Windows Vista Home Basic N 64-bit Edition
- Windows Vista Business
- Windows Vista Business 64-bit Edition
- Windows Vista Business N
- Windows Vista Business N 64-bit Edition
- Windows Vista Home Premium
- Windows Vista Home Basic 64-bit Edition
- Windows Vista Home Premium 64-bit Edition
- Windows Vista Ultimate
- Windows Vista Ultimate 64-bit Edition
- Microsoft Windows XP Home Edition
- Microsoft Windows XP Professional
- Windows Server 2008 Standard
- Windows Server 2008 Enterprise
- Windows Server 2008 Datacenter
- kbhowto kbexpertiseinter kbinfo KB251192
Windows Service的官方描述,抄下来(不写obj就是LocalSystem)的更多相关文章
- quartz.net结合Topshelf实现windows service服务托管的作业调度框架
topshelf可以很简单方便的实现windows service服务,详见我的一篇博客的介绍 http://www.cnblogs.com/xiaopotian/articles/5428361.h ...
- 分别在.NET Framework 与 .NET Core 框架下 编写Windows Service(windows服务程序)
前言,为什么会分别在两个框架下编写Windows Service,是因为最近在做区块链这块,使用的是NEO(小蚁区块链)的相关技术,NEO使用的是.net core 2.1,业务上需要写两个程序,一个 ...
- 创建Windows Service
基本参照使用C#创建Windows服务,添加了部分内容 目录 创建Windows Service 可视化管理Windows Service 调试 示例代码 创建Windows Service 选择C# ...
- C#创建、安装、卸载、调试Windows Service(Windows 服务)的简单教程
前言:Microsoft Windows 服务能够创建在它们自己的 Windows 会话中可长时间运行的可执行应用程序.这些服务可以在计算机启动时自动启动,可以暂停和重新启动而且不显示任何用户界面.这 ...
- 使用Python写Windows Service服务程序
1.背景 如果你想用Python开发Windows程序,并让其开机启动等,就必须写成windows的服务程序Windows Service,用Python来做这个事情必须要借助第三方模块pywin32 ...
- C#制作Windows service服务系列二:演示一个定期执行的windows服务及调试(windows service)
系列一: 制作一个可安装.可启动.可停止.可卸载的Windows service(downmoon原创) 系列二:演示一个定期执行的windows服务及调试(windows service)(down ...
- 安装TortoiseGit出现提示“您必须安装带有更新版本Windows Installer服务的Windows Service Pack”-解决方法
我的系统是xp sp3安装TortoiseGit时出现了错误提示“您必须安装带有更新版本Windows Installer服务的Windows Service Pack”. 解决方法,到微软官方下载相 ...
- C# Windows Service调用IBM Lotus Notes发送邮件
近日研究了下IBM Lotus Mail,这货果然是麻烦,由于公司策略,没有开放smtp,很多系统邮件都没有办法发送,于是入手google学习Lotus Mail,想做成Windows服务,提供wcf ...
- windows service宿主web api使用"依赖注入"和“控制反转”的技术实践
前言 自从几年前抛弃wcf,使用web api 来做服务器端开发之后,就不再迷惑了.但是因为本来从事传统行业管理软件开发,一般都以分布式应用开发为主.纯BS还是比较少,于是比较喜欢用windows s ...
随机推荐
- Oracle如何实现跨数据库查询
转发:http://www.linuxidc.com/Linux/2012-02/53974.htm 实现结果:在一个数据库中某个用户下编写一个存储过程,在存储过程中使用DBLINK连接另一个数据库, ...
- Struts2详解
struts2框架是SSH框架集中的框架之一,是一个基于MVC设计模式的Web应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器层(Controller)来建立 ...
- HDU 1222 Wolf and Rabbit(gcd)
HDU 1222 Wolf and Rabbit (最大公约数)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- 《JavaScript权威指南》拾遗(上)
一.语言基础 1.javascript中,只有null和undefined是无法拥有方法的值,它们都没有包装对象.typeof null == ‘object' , typeof un ...
- YII2 Gridview
YII2 Gridview 部分使用规则 1.页面显示的时间戳转换 a. [ 'label'=>'创建日期', 'attribute' => 'created_at', 'filter' ...
- Python之路Day19
志不坚者智不达. 主要内容:Django分页.自定义simpletag.权限管理 Django分页 Django自带了一个分页功能,使用起来很方便.官方文档 先来看一下效果图: 后台代码: def c ...
- poj 2513
http://poj.org/problem?id=2513 73348K 1438MS C++ 1614B解题思路:欧拉路的应用 要点 :1.判断连通性 ...
- NET Core1
NET Core .net core最近园子讨论频率很高的话题,从不久前发布正式版本后,也是开始从netcore官网一步一步走向学习之路:.net跨平台的设计让人很是兴奋起来,因为做了多年的互联网研发 ...
- mysql基础(mysql数据库导入到处) 很基础很实用
一.MYSQL的命令行模式的设置:桌面->我的电脑->属性->环境变量->新建->PATH=“:path\mysql\bin;”其中path为MYSQL的安装路径.二.简 ...
- Qt下如何修改文件的时间(全平台修改)
提供一个全平台修改文件的时间的方法,希望大家喜欢 /* UTIME.C: This program uses _utime to set the * file-modification time to ...