简体   繁体   English

InstallUtil使用哪个框架版本安装服务?

[英]InstallUtil which framework version was used to install service?

Scenario: older 2.0 windows services installed on a server but if I try to use the newer 4.5 InstallUtil to uninstall I am getting an error. 方案:服务器上安装了较旧的2.0 Windows服务,但是如果我尝试使用较新的4.5 InstallUtil进行卸载,则会收到错误消息。

We use an application that uses the InstallUtil service to uninstall/install windows services. 我们使用一个使用InstallUtil服务的应用程序来卸载/安装Windows服务。 Is there any way to check which framework version of InstallUtil was used to install the service? 有什么方法可以检查用于安装服务的InstallUtil的哪个框架版本? So that depending on which version was used I can pass the correct InstallUtil Path to the method 这样,根据使用的版本,我可以将正确的InstallUtil路径传递给该方法

Instead of InstallUtil try using Windows own SC.EXE 代替InstallUtil尝试使用Windows自己的SC.EXE

Eg to uninstall service: 例如卸载服务:

NET stop "Your Service Name"
SC delete "Your Service Name" 

(first command used to stop service if it's still running) (第一个用于停止服务的命令,如果它仍在运行)

Similarly you can use SC.EXE to create and start service. 同样,您可以使用SC.EXE创建和启动服务。 This way you're not depending on InstallUtil or its specific version. 这样,您就不必依赖InstallUtil或其特定版本。

I'm able to get the details I want using this code: 我可以使用以下代码获取所需的详细信息:

const string dotNetFourPath = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + "servicename "; //servicename here
using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(dotNetFourPath))
{
    Console.WriteLine(registryKey.GetValue("EventMessageFile")); //returns EventMessageFile - Value Data
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM