public static void UninstallService(System.Configuration.Install.Installer installer) { System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller; System.ServiceProcess.ServiceInstaller serviceInstaller; FindInstallers(installer, out serviceProcessInstaller, out serviceInstaller); UninstallService(serviceInstaller.ServiceName); }
void ShortBusServiceInstaller_BeforeInstall(object sender, System.Configuration.Install.InstallEventArgs e) { System.Console.WriteLine("*************************************************************"); System.Configuration.Install.Installer x = (sender as System.Configuration.Install.Installer); string sname = "ShortBusSubscriber"; string sdesc = "Short Bus Subscriber"; string dname = "Short Bus Subscriber"; if (!string.IsNullOrEmpty(Program.serviceName)) { sname = Program.serviceName; } if (!string.IsNullOrEmpty(Program.serviceDesc)) { sdesc = Program.serviceDesc; } if (!string.IsNullOrEmpty(Program.displayName)) { dname = Program.displayName; } List <KeyValuePair <string, string> > paramsAsList = new List <KeyValuePair <string, string> >(); Console.WriteLine("f**k"); foreach (string k in x.Context.Parameters.Keys) { paramsAsList.Add(new KeyValuePair <string, string>(k, x.Context.Parameters[k])); } string keyValue = null; keyValue = paramsAsList.FirstOrDefault(g => g.Key.Equals("servicename", System.StringComparison.OrdinalIgnoreCase)).Value; if (!string.IsNullOrEmpty(keyValue)) { sname = keyValue; } keyValue = paramsAsList.FirstOrDefault(g => g.Key.Equals("servicedescription", System.StringComparison.OrdinalIgnoreCase)).Value; if (!string.IsNullOrEmpty(keyValue)) { sdesc = keyValue; } keyValue = paramsAsList.FirstOrDefault(g => g.Key.Equals("displayname", System.StringComparison.OrdinalIgnoreCase)).Value; if (!string.IsNullOrEmpty(keyValue)) { dname = keyValue; } this.ServiceInstaller1.ServiceName = sname; this.ServiceInstaller1.Description = sdesc; this.ServiceInstaller1.DisplayName = dname; Console.WriteLine("Service Name: {0}", sname); Console.WriteLine("Service Description: {0}", sdesc); Console.WriteLine("Display Name: {0}", dname); }
public static void InstallService(System.Configuration.Install.Installer installer) { System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller; System.ServiceProcess.ServiceInstaller serviceInstaller; FindInstallers(installer, out serviceProcessInstaller, out serviceInstaller); ServiceAccountDescriptor accountDescriptor = new ServiceAccountDescriptor(serviceProcessInstaller); InstallService(serviceInstaller.ServiceName, serviceInstaller.DisplayName, serviceInstaller.StartType, accountDescriptor); }
public static void ShowException(System.Configuration.Install.Installer installer, string message, Exception ex) { message = string.Format("{0}\r\n{1}\r\n", AnErrorHasOccurredAndItWillBeIgnored, message, ex.ToString() ); MessageBox.Show(Installation.InstallerWindowWrapper(installer), message); }
//--------------------------------------------------------------------- // Static members /// <summary> /// Adds the installers that handle the installation of the application /// as a native Windows service. /// </summary> /// <param name="installer">The application's installer.</param> /// <param name="props">The service installation properties.</param> public static void AddInstallers(System.Configuration.Install.Installer installer, ServiceInstallProperties props) { var serviceInstaller = new ServiceInstaller(); var serviceProcessInstaller = new ServiceProcessInstaller(); serviceInstaller.DisplayName = props.Name; serviceInstaller.ServiceName = props.Name; serviceInstaller.StartType = props.StartMode; serviceProcessInstaller.Account = props.Account; serviceProcessInstaller.Username = props.UserName; serviceProcessInstaller.Password = props.Password; installer.Installers.AddRange(new System.Configuration.Install.Installer[] { serviceProcessInstaller, serviceInstaller }); }
/// <summary> /// Adds performance counter installers for each counter represented in this set /// to the installer passed. /// </summary> /// <param name="installer">The target installer.</param> public void AddInstallers(System.Configuration.Install.Installer installer) { PerformanceCounterInstaller ctrInstaller; ctrInstaller = new PerformanceCounterInstaller(); ctrInstaller.CategoryName = this.categoryName; ctrInstaller.CategoryHelp = this.categoryHelp; foreach (var counter in counters.Values) { ctrInstaller.Counters.Add(new CounterCreationData(counter.Name, counter.Help, counter.Type)); } installer.Installers.Add(ctrInstaller); }
private static void FindInstallers(System.Configuration.Install.Installer installer, out System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller, out System.ServiceProcess.ServiceInstaller serviceInstaller) { serviceProcessInstaller = null; serviceInstaller = null; foreach (System.Configuration.Install.Installer nestedInstaller in installer.Installers) { if (nestedInstaller is System.ServiceProcess.ServiceProcessInstaller) { serviceProcessInstaller = (System.ServiceProcess.ServiceProcessInstaller)nestedInstaller; } else if (nestedInstaller is System.ServiceProcess.ServiceInstaller) { serviceInstaller = (System.ServiceProcess.ServiceInstaller)nestedInstaller; } if (serviceProcessInstaller != null && serviceInstaller != null) { break; } } if (serviceProcessInstaller == null || serviceInstaller == null) { throw new ArgumentException(); } }
public static void Test1(System.Configuration.Install.Installer installer) { Contract.Assert(installer.Installers != null); }
public void Remove(System.Configuration.Install.Installer value) { }
public void Insert(int index, System.Configuration.Install.Installer value) { }
public int IndexOf(System.Configuration.Install.Installer value) { throw null; }
public bool Contains(System.Configuration.Install.Installer value) { throw null; }