场景:在服务器上安装了较旧的2.0 InstallUtil服务,但如果我尝试使用较新的4.5 windows服务来卸载,则会收到错误消息。
我们使用一个使用InstallUtil服务的应用程序来卸载/安装windows服务。有没有办法检查InstallUtil的哪个框架版本是用来安装服务的?因此,根据所使用版本,我可以将正确的InstallUtil路径传递给该方法
发布于 2014-05-29 23:37:48
尝试使用Windows自己的SC.EXE而不是InstallUtil
例如,要卸载服务:
NET stop "Your Service Name"
SC delete "Your Service Name" (如果服务仍在运行,则用于停止服务的第一个命令)
类似地,您可以使用SC.EXE创建和启动服务。这样,您就不需要依赖于InstallUtil或其特定版本。
发布于 2014-05-30 21:20:42
我可以使用下面的代码获取我想要的详细信息:
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
}https://stackoverflow.com/questions/23936480
复制相似问题