sc命令以及InstallUtil安装service
1.安装
https://stackoverflow.com/questions/8164859/install-a-windows-service-using-a-windows-command-prompt
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的更多相关文章
- 使用SC命令操作(安装、开启、配置、关闭、删除)Windows下的服务
目录 一.直接使用cmd命令行操作windows服务 二.使用bat批处理-操作windows服务 一.直接使用cmd命令行操作windows服务 1.安装服务 sc create 服务名 binPa ...
- [开发笔记]-使用bat命令来快速安装和卸载Service服务
一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...
- SC命令---安装、开启、配置、关闭 cmd命令行和bat批处理操作windows服务
一.cmd命令行---进行Windows服务操作 1.安装服务 sc create 服务名 binPath= "C:\Users\Administrator\Desktop\win32s ...
- 转载:使用bat命令来快速安装和卸载Service服务
一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...
- (转)SC命令---安装、开启、配置、关闭windows服务 bat批处理
本文转载自:http://blog.csdn.net/moruna/article/details/9190733 废话不多说,看命令行更直接! 一.直接使用cmd来进行服务的一些操作 1.安装服务 ...
- 使用SC命令时注意事项
使用SC命令时注意事项[转] Windows 2003 Server存在一个sc命令,(好像Windows 2000/XP/NT都有这个.)该命令可以手工创建Windows服务(NT Service) ...
- cmd sc命令进行服务操作
sc 命令可以注册.删除和查询系统服务 sc可供选择的参数有很多,这里不详细描述.只介绍简单的最基本的sc使用方式. 1. sc create 创建windows服务 eg: sc \\myserve ...
- C#通过SC命令和静态公共类来操作Windows服务
调用的Windows服务应用程序网址:http://www.cnblogs.com/pingming/p/5115304.html 一.引用 二.公共静态类:可以单独放到类库里 using Syste ...
- 如何在本地数据中心安装Service Fabric for Windows集群
概述 首先本文只是对官方文档(中文,英文)的一个提炼,详细的安装说明还请仔细阅读官方文档. 虽然Service Fabric的官方名称往往被加上Azure,但是实际上(估计很多人不知道)Service ...
随机推荐
- HDU-1052 Tian Ji -- The Horse Racing 贪心 考虑特殊位置(首尾元素)的讨论
题目链接:https://cn.vjudge.net/problem/HDU-1052 题意 田忌赛马问题扩展版 给n匹马,马的能力可以相同 问得分最大多少 思路 贪心做得还是太少,一开始一点思虑都没 ...
- jq 遍历 元素
$("#spec").find("div.gods-spe").each(function(i,n){ var child = $(this).children ...
- java 模拟ajax上传图片
1.maven 引入依赖 <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime --> &l ...
- linux 空间不够了 修改 /boot
1> 查看空间多少:df -h2> 查看当期内核: uname -r3> 查找内核 rpm -qa | grep kernel4> 删除多余的内核 yum remo ...
- C# 获取本地电脑所有的盘符
话不多说,直接上菜: public List<string> GetRemovableDeviceID() { List<string> deviceIDs = new ...
- YII进行数据查询及类库追踪
一般处理过程: 模型进行数据操作,继承自CActiveRecord (活跃记录) AR数据库向上的封装.AR通过OOP面向对象方式操作数据库.AR须要终于转变为详细的sql语句.通过一个中间类(cri ...
- sas数据导入终极汇总-之中的一个
将数据文件读入SAS --DATA Step / PROC IMPORT 1.将SAS文件读入SAS-- data sasuser.saslin; set "F:\sa ...
- Java类和对象11
首先,编写一个类ChongZai,该类中有3个重载的方法void print():其次,再编写一个主类来测试ChongZai类的功能. public class ChongZai { public v ...
- 请教如何用 peewee 实现类似 django ORM 的这种查询效果。
本人新入坑的小白,如有不对的地方请包涵~~~! 在 django 中代码如下:模型定义: class Friends(models.Model): first_id = models.IntegerF ...
- <Sicily>Prime Palindromes
一.题目描述 The number 151 is a prime palindrome because it is both a prime number and a palindrome (it i ...