19 using System.Collections;
20 using System.ComponentModel;
21 using System.Configuration.Install;
22 using System.ServiceProcess;
23 using Microsoft.Win32;
25 namespace LuceneMonitorInstall
30 [RunInstallerAttribute(
true)]
33 private ServiceProcessInstaller processInstaller;
34 private ServiceInstaller serviceInstaller;
38 private System.ComponentModel.Container components = null;
43 InitializeComponent();
51 protected override void Dispose(
bool disposing )
55 if(components != null)
60 base.Dispose( disposing );
64 #region Component Designer generated code
69 private void InitializeComponent()
71 this.processInstaller =
new ServiceProcessInstaller();
72 this.serviceInstaller =
new ServiceInstaller();
73 this.processInstaller.Account = ServiceAccount.LocalSystem;
75 this.serviceInstaller.ServiceName =
"LuceneMonitor";
76 this.serviceInstaller.StartType = ServiceStartMode.Manual;
78 Installers.Add(this.processInstaller);
79 Installers.Add(this.serviceInstaller);
84 public override void Install(IDictionary stateSaver)
87 RegistryKey currentControlSet;
94 base.Install(stateSaver);
96 system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(
"System");
97 currentControlSet = system.OpenSubKey(
"CurrentControlSet");
98 services = currentControlSet.OpenSubKey(
"Services");
99 service = services.OpenSubKey(this.serviceInstaller.ServiceName,
true);
101 service.SetValue(
"Description",
"Lucene Monitor");
107 Console.WriteLine(
"An exception was thrown during service installation:\n" + e.ToString());
114 RegistryKey currentControlSet;
115 RegistryKey services;
121 system = Registry.LocalMachine.OpenSubKey(
"System");
122 currentControlSet = system.OpenSubKey(
"CurrentControlSet");
123 services = currentControlSet.OpenSubKey(
"Services");
124 service = services.OpenSubKey(this.serviceInstaller.ServiceName,
true);
125 service.DeleteSubKeyTree(
"Description");
130 Console.WriteLine(
"Exception encountered while uninstalling service:\n" + e.ToString());
135 base.Uninstall(savedState);