Install Services Without Installutil.exe
Installutil.exe can be used to install services, but what it actually invokes is:
System.Configuration.Install.ManagedInstallerClass.InstallHelper(string[] args)
So instead of depending on an external executable, you can code it embedded in your program.
Install code:
private static string exepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string servicePath = string.Format(@"{0}\{1}", exepath, "myservice.exe");
ManagedInstallerClass.InstallHelper(new string[] { servicePath });
Uninstall code:
private static string exepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string servicePath = string.Format(@"{0}\{1}", exepath, "myservice.exe");
ManagedInstallerClass.InstallHelper(new string[] { "/u", servicePath });