1.安装

https://stackoverflow.com/questions/8164859/install-a-windows-service-using-a-windows-command-prompt

https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-install-and-uninstall-services

https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool

Navigate to the installutil.exe in your .net folder (for .net 4 it's C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319

这两个路径下的InstallUtil.exe都可以使用,如果项目使用的是AnyCPU进行编译

需要注意的是:必须使用管理员权限运行命令行工具。

Example

installutil /servicename="LFXSVC_FileExchange5.0_20170818" /displayname="FileExchange5.0_SourceCode"  /description="description of application" .\LISA.FileExchange.Service.exe

Remarks

需要注意的是,servicename不可以重复,并且displayname也不可以重复

2.移除,启动,停止

sc delete

C:\Windows\system32>sc delete LFXSVC_FileExchange5.0_20170831151735.535
[SC] DeleteService SUCCESS

sc start

sc stop

3.重命名Service

https://superuser.com/questions/975832/how-to-change-windows-service-name-after-creating-it

To change the display name of a service you can run:

sc config "Old service name" displayname= "New service name"

需要注意的是,config后面的参数是service name。这个必须通过服务的property才能看到,控制面板上显示的是DisplayName。

C:\Windows\system32>sc config LFXSVC_FileExchange5.0 DisplayName= "FileExchange5.0_Installer"

这个命令只在cmd中有效,在powershell中会遇到问题

PowerShell中的sc不是cmd中的,可以使用help sc查看

NAME
Set-Content

SYNTAX
Set-Content [-Path] <string[]> [-Value] <Object[]> [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <
string[]>] [-Force] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-NoNewline] [-Encoding <Fi
leSystemCmdletProviderEncoding> {Unknown | String | Unicode | Byte | BigEndianUnicode | UTF8 | UTF7 | UTF32 | Ascii
| Default | Oem | BigEndianUTF32}] [-Stream <string>] [<CommonParameters>]

Set-Content [-Value] <Object[]> -LiteralPath <string[]> [-PassThru] [-Filter <string>] [-Include <string[]>] [-Excl
ude <string[]>] [-Force] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-NoNewline] [-Encodin
g <FileSystemCmdletProviderEncoding> {Unknown | String | Unicode | Byte | BigEndianUnicode | UTF8 | UTF7 | UTF32 |
Ascii | Default | Oem | BigEndianUTF32}] [-Stream <string>] [<CommonParameters>]

ALIASES
sc

REMARKS
Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
-- To download and install Help files for the module that includes this cmdlet, use Update-Help.
-- To view the Help topic for this cmdlet online, type: "Get-Help Set-Content -Online" or
go to http://go.microsoft.com/fwlink/?LinkID=113392.

4.查询服务

http://www.cnblogs.com/chucklu/p/5847330.html    查看这篇文章里的1.5

http://www.cnblogs.com/chucklu/p/7248604.html

sc命令以及InstallUtil安装service的更多相关文章

  1. 使用SC命令操作(安装、开启、配置、关闭、删除)Windows下的服务

    目录 一.直接使用cmd命令行操作windows服务 二.使用bat批处理-操作windows服务 一.直接使用cmd命令行操作windows服务 1.安装服务 sc create 服务名 binPa ...

  2. [开发笔记]-使用bat命令来快速安装和卸载Service服务

    一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...

  3. SC命令---安装、开启、配置、关闭 cmd命令行和bat批处理操作windows服务

      一.cmd命令行---进行Windows服务操作 1.安装服务 sc create 服务名 binPath= "C:\Users\Administrator\Desktop\win32s ...

  4. 转载:使用bat命令来快速安装和卸载Service服务

    一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...

  5. (转)SC命令---安装、开启、配置、关闭windows服务 bat批处理

    本文转载自:http://blog.csdn.net/moruna/article/details/9190733 废话不多说,看命令行更直接! 一.直接使用cmd来进行服务的一些操作 1.安装服务 ...

  6. 使用SC命令时注意事项

    使用SC命令时注意事项[转] Windows 2003 Server存在一个sc命令,(好像Windows 2000/XP/NT都有这个.)该命令可以手工创建Windows服务(NT Service) ...

  7. cmd sc命令进行服务操作

    sc 命令可以注册.删除和查询系统服务 sc可供选择的参数有很多,这里不详细描述.只介绍简单的最基本的sc使用方式. 1. sc create 创建windows服务 eg: sc \\myserve ...

  8. C#通过SC命令和静态公共类来操作Windows服务

    调用的Windows服务应用程序网址:http://www.cnblogs.com/pingming/p/5115304.html 一.引用 二.公共静态类:可以单独放到类库里 using Syste ...

  9. 如何在本地数据中心安装Service Fabric for Windows集群

    概述 首先本文只是对官方文档(中文,英文)的一个提炼,详细的安装说明还请仔细阅读官方文档. 虽然Service Fabric的官方名称往往被加上Azure,但是实际上(估计很多人不知道)Service ...

随机推荐

  1. pyinstall 常见错误

    字符编码错误: https://blog.csdn.net/weixin_42426496/article/details/81102665 https://blog.csdn.net/qq_4206 ...

  2. 学习参考《Flask Web开发:基于Python的Web应用开发实战(第2版)》中文PDF+源代码

    在学习python Web开发时,我们会选择使用Django.flask等框架. 在学习flask时,推荐学习看看<Flask Web开发:基于Python的Web应用开发实战(第2版)> ...

  3. c++常见操作的模板

    1.统计时间 #include<ctime> clock_t startTime = clock(); code(); clock_t endTime = clock(); cout &l ...

  4. UVa 10954 Add All 贪心

    贪心   每一次取最小的两个数,注意相加的数也要算' #include<cstring> #include<iostream> #include<cstdio> # ...

  5. pre自动换行

    从word复制到html中的文本,用pre能够原汁原味的展示出来,但是会出现超过屏蔽界限的情况. 需要进行换行处理. 加上一句css pre { white-space: pre-wrap; word ...

  6. [NOI2013模拟] BZOJ4705 棋盘游戏 解题报告(组合计数)

    莫名打不开这道题的链接,请读者自行搜索 Description 有一个N*M的棋盘,初始每个格子都是白色的.行操作是指选定某一行,将这行所有格子的颜色取反(黑白互换).列操作是指选定某一列,将这列所有 ...

  7. Objects and values

    If we execute these assignment statements: We know that a and b both refer to a string, but we don’t ...

  8. Webfont 的兼容性问题[持续更新]

    低版安卓手机的 webview 显示不了,另外黑莓手机显示出来是这样: 生成工具: 离线字体生成工具:webfont 在线字体生成平台:icomoon.io, iconfont.cn均有问题 其他一些 ...

  9. python3.x学习笔记2(基础知识)

    1.元组元组其实跟列表差不多,也是存一组数,只是它一旦创建,便不能在修改,所以又叫只读列表语法:names =('shgd','sjdh') 它只有两个方法,一个是count,一个是index 2.字 ...

  10. CUDA笔记(七)

    今天集中时间找程序的问题.于是发现: 首先,程序里的kernel想要调试,必须用nsight. 于是一堆找.http://www.nvidia.com/object/nsight.html http: ...