.net – 使用InstallUtil卸载不存在的服务
发布时间:2020-12-13 22:43:52 所属栏目:Windows 来源:网络整理
导读:我正在使用我的服务的pre和post构建事件来卸载和安装服务.唯一的问题是,第一次另一个开发人员使用预构建事件时它失败了,因为尚未安装该服务. 我卸载的当前预构建事件是 %WinDir%Microsoft.NETFrameworkv4.0.30319InstallUtil /u $(TargetPath) 如何在服
我正在使用我的服务的pre和post构建事件来卸载和安装服务.唯一的问题是,第一次另一个开发人员使用预构建事件时它失败了,因为尚未安装该服务.
我卸载的当前预构建事件是 %WinDir%Microsoft.NETFrameworkv4.0.30319InstallUtil /u $(TargetPath) 如何在服务已经安装时才??使用它来卸载?
您可以使用Microsoft SC工具(Sc.exe)查询服务的状态,甚至可以创建或删除服务.这是一篇关于使用此命令的文章:
http://support.microsoft.com/kb/251192
从命令提示符窗口(为强调编辑的内容): C:windowssystem32>sc DESCRIPTION: SC is a command line program used for communicating with the Service Control Manager and services. USAGE: sc <server> [command] [service name] <option1> <option2>... The option <server> has the form "ServerName" 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. continue--------Sends a CONTINUE control request to a service. stop------------Sends a STOP request to a service. delete----------Deletes a service (from the registry). create----------Creates a service. (adds it to the registry). 运行此命令以查询(A)存在且(B)不存在的服务导致: (一个) C:WindowsSystem32>sc query W32Time SERVICE_NAME: W32Time TYPE : 20 WIN32_SHARE_PROCESS STATE : 1 STOPPED WIN32_EXIT_CODE : 1077 (0x435) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 (B) C:WindowsSystem32>sc query nothere [SC] EnumQueryServicesStatus:OpenService FAILED 1060: The specified service does not exist as an installed service. 因此,您可以在尝试使用以下内容删除它之前测试服务的存在 – (原谅令人厌恶地使用FOR语句,我不确定如何将sc命令的输出捕获到变量或在IF声明中使用它) – set svcname=W32Time set svc=exists for /f "delims=" %%o in ('sc query %svcname% ^| find "FAIL"') do set svc=notexists if "%svc%"=="exists" sc delete %svcname% (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 如何找出连接到互联网的NIC?
- 命令行 – 在Windows 2008 Server中从MP3 / WAV文件生成可视
- 【原】无脑操作:Windows下搭建Kafka运行环境
- windows-server-2008 – 如何从一个IP允许RDP访问Windows 2
- [转帖]Ansible批量远程管理Windows主机(部署与配置)
- windows – 追踪哪个进程/程序导致Kerberos预身份验证错误(
- HoTMaiL或Windows Live ID是否支持OpenID认证?
- 是否可以在Windows XP中安装/卸载物理硬盘?
- 是否可以在Windows上为tcp slow start配置初始窗口大小?
- windows-10 – Windows 10和网络驱动器
推荐文章
站长推荐
- Windows Phone 8 – 防止Windows Phone 8上的自动
- windows-7 – SSD硬盘RAID-0效率?
- windows-server-2008 – 可移动卷卸载:驱动器号
- .net – 从TripleDES更改Microsoft配置文件加密方
- windows-phone-7 – 如何将图像发送到php web服务
- 正在阅读:Win10激活失败提示错误0xC004C003的原
- 在Windows和Linux上构建C
- .net – 无法加载DLL’SqlServerSpatial.dll’
- windows-8 – 您的开发人员许可证已过期(Windows
- ms-access – PDF缩略图和Microsoft Access中的预
热点阅读