我需要以编程方式安装服务(它甚至可以使用 InstallUtil 完成,但不能手动完成)
我有以下代码,但无法弄清楚如何正确执行它,因为该代码要求提供一些我不知道的类信息,我需要知道如何使用它才能使用 .exe 执行它。代码如下:
public static void InstallService(string ExeFilename)
{
System.Configuration.Install.AssemblyInstaller Installer = new System.Configuration.Install.AssemblyInstaller(ExeFilename,null);
Installer.UseNewContext = true;
Installer.Install(null);
Installer.Commit(null);
}