大佬教程收集整理的这篇文章主要介绍了.net – 使用InstallUtil卸载不存在的服务,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我卸载的当前预构建事件是
%WinDir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil /u $(TargetPath)
如何在服务已经安装时才使用它来卸载?
C:\windows\system32>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:\Windows\System32>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:\Windows\System32>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%
以上是大佬教程为你收集整理的.net – 使用InstallUtil卸载不存在的服务全部内容,希望文章能够帮你解决.net – 使用InstallUtil卸载不存在的服务所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。