用命令 安装/卸载 windows服务(转)
第一种方法:
1. 开始 ->运行 ->cmd
2. cd到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727(Framework版本号按IIS配置)
3. 安装服务: 运行命令行 InstallUtil.exe E:/test.exe
卸载服务: 运行命令行 InstallUtil.exe -u E:/test.exe
这样就能删除了,但如果还是不能删除的话,没关系下面还有一种方法。
第二种方法:
运行-->cmd-->到c:\windows\system32文件夹下-->输入sc delete <服务名称>,然后就可以把服务卸载了
这时候,我们可以用另外一个命令来卸载,如下:
C:\WINDOWS\system32>sc delete MyService
其中的 MyService 是你的服务的名字,比如如下的服务截图,它的卸载命令就可以如下写:
sc delete "服务名"
当然你也可以用这个工具create,start,stop服务。比如,我们就可以用下面的命令,安装服务,并把服务启动起来。
installutil HongjunGuo.JobsWindowsService.exe
sc start "服务名"
C# 卸载windows服务
//卸载服务
private void btnUninstall_Click(object sender, EventArgs e)
{
string path = GetWindowsServiceInstallPath("KylintechService");
string p_Path = path + "\\Kylintech_Service.exe";
string p_ServiceName = "KylintechService";
UnInstallService(p_Path, p_ServiceName);
this.lblStart.Text = "状态:服务已卸载";
}
//二、卸载windows服务:
private void UnInstallService(string filepath, string p_ServiceName)
{
try
{
if (ServiceIsExisted(p_ServiceName))
{
//UnInstall Service
AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();
myAssemblyInstaller.UseNewContext = true;
myAssemblyInstaller.Path = filepath;
myAssemblyInstaller.Uninstall(null);
myAssemblyInstaller.Dispose();
}
}
catch (Exception ex)
{
throw new Exception("unInstallServiceError\n" + ex.Message);
}
}
//三、判断window服务是否存在:
private bool ServiceIsExisted(string serviceName)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController s in services)
{
if (s.ServiceName == serviceName)
{
return true;
}
}
return false;
}
用命令 安装/卸载 windows服务(转)的更多相关文章
- 二种方法安装卸载Windows服务的命令
第一种方法:通过Dos命令安装系统服务1. 开始 运行输入 cmd 进入dos窗口2. cd命令进入到C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727目录下, ...
- 安装&卸载Windows服务
使用.NET Framework的工具InstallUtil.exe. 安装服务 C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.e ...
- C# 远程服务器 安装、卸载 Windows 服务,读取远程注册表,关闭杀掉远程进程
这里安装windows服务我们用sc命令,这里需要远程服务器IP,服务名称.显示名称.描述以及执行文件,安装后需要验证服务是否安装成功,验证方法可以直接调用ServiceController来查询服务 ...
- 使用InstallUtil安装及卸载Windows服务的具体操作 Visual Studio 2012版本
关于Visual Studio 2012中使用InstallUtil对Windows服务进行安装与卸载的文章,在MSDN中的http://msdn.microsoft.com/en-us/librar ...
- 批处理文件安装与卸载Windows服务
//安装Windows服务 将RECPost.exe和RECPostService替换成自己的项目名称和服务名称,并将文件保存成bat格式.其中%cd%是获取相对路径 @echo off set fi ...
- 【先定一个小目标】Redis 安装成windows服务-开机自启
1.第一步安装成windows服务的,开机自启动 redis-server --service-install redis.windows.conf 2.启动\关闭 redis-server --se ...
- 【C#】使用bat文件安装卸载Window服务
1.安装服务 @echo off @title 安装windows服务path %SystemRoot%\Microsoft.NET\Framework\v4.0.30319echo========= ...
- Redis是可以安装成windows服务-开机自启
其实Redis是可以安装成windows服务的,开机自启动,命令如下 redis-server --service-install redis.windows.conf 安装完之后,就可看到Redis ...
- 使用srvany.exe将程序安装成windows服务的详细教程
srvany.exe介绍 srvany.exe是Microsoft Windows Resource Kits工具集的一个实用的小工具,用于将任何EXE程序作为Windows服务运行.也就是说srva ...
随机推荐
- sensitivity and specificity(敏感性和特异性)
医学.机器学习等等,在统计结果时时长会用到这两个指标来说明数据的特性.
- Machine Learning - 第5周(Neural Networks: Learning)
The Neural Network is one of the most powerful learning algorithms (when a linear classifier doesn't ...
- 界面显示这个时间格式的js代码: 2016年1月19日 星期二 乙未(羊)年 腊月初十
today=new Date();function initArray(){ this.length=initArray.arguments.length for(var i=0;i<this. ...
- b.BIO连接器整体框图
上一讲讲解过NIO的框图,可以看来,NIO通道是目前Tomcat7以后的默认的通道的推荐配置,在Tomcat6和以前的配置中,BIO是主流的配置: 只需要修改protocol协议部分即可,而后续还有A ...
- virutalbox虚拟机硬盘扩容
大小改变为30GB VBoxManage modifyhd d:\newxp.vdi --resize 30000 然后用diskgenius扩从容量
- 制作ubuntu安装u盘
Ubuntu官方中文译名为友帮拓,是一款开源免费的linux操作系统.与其他的linux操作系统不同之处在于Ubuntu的软件包清单只包含那些高质量的重要应用程序,因此深受广大linux用户的喜爱,那 ...
- phantomjs 乱码解决
system = require('system') //传递一些需要的参数给js文件 address = system.args[1];//获得命令行第二个参数 ,也就是指定要加载的页面地址,接下来 ...
- C#压缩加密和vb压缩加密
string[] FileProperties = new string[2]; FileProperties[0] = "C:\\a\\";//待压缩文件目录 FilePrope ...
- 你不知道的JavaScript--大白话讲解Promise
转载:http://blog.csdn.net/i10630226/article/details/50867792 一.Promise小试 复杂的概念先不讲,我们先简单粗暴地把Promise用一下, ...
- php -l 检查文件是否语法错误
有时候在进行网页开发的时候,后台文件的语法错误比较难检查出来,这时候使用php -l filename可对文件的语法进行检查.