bool Install(bool isInstall) { try { TransactedInstaller installer = new TransactedInstaller(); installer.Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); installer.Installers.Add(new ServiceInstaller { DisplayName = "小明后台播放器", ServiceName = serviceName, Description = "小明后台播放器", StartType = ServiceStartMode.Automatic, }); installer.Context = new InstallContext(); installer.Context.Parameters["assemblypath"] = AppDomain.CurrentDomain.BaseDirectory + "LittleMingPlayService.exe"; if (isInstall) { installer.Install(new Hashtable()); } else { installer.Uninstall(null); } } catch (Exception er) { return(false); } return(true); }
private bool RunTransactedInstaller(Installer serviceIinstaller, bool install) { bool flag; var installer = new TransactedInstaller(); try { installer.Installers.Add(serviceIinstaller); var cmd = new[] { string.Format("/assemblypath={0}", Assembly.GetEntryAssembly().Location) }; var context = new InstallContext("", cmd); installer.Context = context; if (install) { installer.Install(new Hashtable()); } else { installer.Uninstall(null); } flag = true; } catch (Exception) { flag = false; } finally { installer.Dispose(); } return(flag); }
/// <summary> /// 卸载window服务 /// </summary> public void UninstallService() { if (InstallerConfig == null) { Console.WriteLine("无效的服务配置项!"); return; } ServiceController controller = InstallerUtils.LookupService(InstallerConfig.ServiceName); if (controller != null) { try { TransactedInstaller installer = GetTransactedInstaller(); installer.Uninstall(null); } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { Console.WriteLine("服务{0}尚未安装,输入'/?'查看帮助!", InstallerConfig.ServiceName); } }
private bool UninstallService() { try { if (ServiceIsExisted(_svcName)) { TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(_svcAppName, null); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Uninstall(null); MessageBox.Show("卸载服务成功!"); return(true); } else { MessageBox.Show("服务不存在"); return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// 配置服务(服务安装及卸载) /// </summary> /// <param name="serviceName"></param> /// <param name="install"></param> public static void ConfigService(string serviceName, bool install) { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); //这里的前置服务是告诉Windows,启动我的时候,记得要先等待SQLServer启动,我需要用到它 ti.Installers.Add(new ServiceInstaller { DisplayName = serviceName, //友好名(DisplayName即为任务管理器、服务管理器中看到的服务名) ServiceName = serviceName, //服务名 Description = "MicroID微检系统数据后台服务", //说明 ServicesDependedOn = new string[] { "MSSQLSERVER" }, //前置服务 StartType = ServiceStartMode.Automatic //运行方式 }); ti.Context = new InstallContext(); ti.Context.Parameters["assemblypath"] = "\"" + Assembly.GetEntryAssembly().Location + "\" /service"; if (install) { ti.Install(new Hashtable()); } else { ti.Uninstall(null); } }
/// <summary> /// 卸载服务。 /// </summary> /// <returns></returns> public static bool UninstallService() { // 检测服务是否存在。 if (!IsWindowsServiceInstalled(SERVICE_NAME)) { return(true); } // 在卸载服务前需要停止服务。 StopService(); // 检测相应的服务文件是否存在。 if (!IsServiceFileExists()) { OOPS(SERVICE_FILE_NOT_EXIST); return(false); } try { string[] cmdline = {}; TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(GetServiceFilePath(), cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Uninstall(null); } catch (Exception ex) { OOPS(UNINSTALL_SERVICE_ERROR + ex.Message); return(false); } return(true); }
/// <summary> /// The main entry point for the application. /// </summary> private static void Main(string[] args) { NameValueCollection appSettings = ConfigurationManager.AppSettings; appSettings.Set("GentleConfigFile", String.Format(@"{0}\gentle.config", PathManager.GetDataPath)); string opt = null; if (args.Length >= 1) { opt = args[0]; } if (opt != null && opt.ToUpperInvariant() == "/INSTALL") { TransactedInstaller ti = new TransactedInstaller(); ProjectInstaller mi = new ProjectInstaller(); ti.Installers.Add(mi); String path = String.Format("/assemblypath={0}", System.Reflection.Assembly.GetExecutingAssembly().Location); String[] cmdline = { path }; InstallContext ctx = new InstallContext("", cmdline); ti.Context = ctx; ti.Install(new Hashtable()); return; } if (opt != null && opt.ToUpperInvariant() == "/UNINSTALL") { TransactedInstaller ti = new TransactedInstaller(); ProjectInstaller mi = new ProjectInstaller(); ti.Installers.Add(mi); String path = String.Format("/assemblypath={0}", System.Reflection.Assembly.GetExecutingAssembly().Location); String[] cmdline = { path }; InstallContext ctx = new InstallContext("", cmdline); ti.Context = ctx; ti.Uninstall(null); return; } // When using /DEBUG switch (in visual studio) the TvService is not run as a service // Make sure the real TvService is disabled before debugging with /DEBUG if (opt != null && opt.ToUpperInvariant() == "/DEBUG") { Service1 s = new Service1(); s.DoStart(new string[] { "/DEBUG" }); do { Thread.Sleep(100); } while (true); } // More than one user Service may run within the same process. To add // another service to this process, change the following line to // create a second service object. For example, // // ServicesToRun = new ServiceBase[] {new Service1(), new MySecondUserService()}; // ServiceBase[] ServicesToRun = new ServiceBase[] { new Service1() }; ServiceBase.Run(ServicesToRun); }
public static void ConfigService( string serviceName, bool install, ServiceStartMode mode = ServiceStartMode.Automatic, string assemblypath = "", string displayName = "", string description = "") { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); ti.Installers.Add(new ServiceInstaller { DisplayName = string.IsNullOrEmpty(displayName) == true ? serviceName : displayName, ServiceName = serviceName, Description = string.IsNullOrEmpty(description) == true ? serviceName : description, StartType = mode //运行方式 }); ti.Context = new InstallContext(); if (install) { ti.Context.Parameters["assemblypath"] = "\"" + assemblypath + "\" /service"; ti.Install(new Hashtable()); } else { StopService(serviceName); ti.Uninstall(null); } }
private static void DoUninstall(IDictionary <string, string> options) { String serviceName = options[OPT_SERVICE_NAME]; if (serviceName != null) { ProjectInstaller.ServiceName = serviceName; } TransactedInstaller ti = new TransactedInstaller(); string[] cmdline = { Assembly.GetExecutingAssembly().Location }; AssemblyInstaller ai = new AssemblyInstaller( cmdline[0], new string[0]); ti.Installers.Add(ai); InstallContext ctx = new InstallContext("uninstall.log", cmdline); ti.Context = ctx; ti.Uninstall(null); }
/// <summary> /// 配置服务 /// </summary> /// <param name="serviceName"></param> /// <param name="install"></param> public static void ConfigService(string serviceName, bool install) { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); ti.Installers.Add(new ServiceInstaller { DisplayName = serviceName, ServiceName = serviceName, Description = "REST API FOR AHU", StartType = ServiceStartMode.Automatic//运行方式 }); ti.Context = new InstallContext(); ti.Context.Parameters["assemblypath"] = "\"" + Assembly.GetEntryAssembly().Location + "\" /service"; if (install) { ti.Install(new Hashtable()); } else { ti.Uninstall(null); } }
private void RunInstallTask(CommandArguments commandArguments, Assembly executingAssembly) { try { TransactedInstaller transactedInstaller = new TransactedInstaller(); GenericInstaller genericInstaller = new GenericInstaller(commandArguments); genericInstaller.AfterInstall += new InstallEventHandler(this.OnAfterInstallBase); genericInstaller.AfterUninstall += new InstallEventHandler(this.OnAfterUninstallBase); transactedInstaller.Installers.Add((Installer)genericInstaller); InstallContext installContext = new InstallContext("", new string[1] { string.Format("/assemblypath={0}", (object)executingAssembly.Location) }); transactedInstaller.Context = installContext; if (commandArguments.ActionType == ActionType.Install) { transactedInstaller.Install((IDictionary) new Hashtable()); } else { transactedInstaller.Uninstall((IDictionary)null); } } catch { Console.WriteLine("Error performing " + ((object)commandArguments.ActionType).ToString() + " task"); } }
//---------------------- Private --------------------------------------------------- static void runInstaller(string[] pArgs) { if (pArgs.Length != 2) { Console.WriteLine("Usage: 'appname /install version' or '/uninstall version'"); return; } var _ti = new TransactedInstaller(); var _cmdLine = new string[1] { string.Format("/assemblypath={0}", Assembly.GetExecutingAssembly().Location) }; _ti.Context = new InstallContext(string.Empty, _cmdLine); _ti.Installers.Add(new RbrServiceInstaller(pArgs[1], pArgs[2])); if (pArgs[0].ToLower() == "/install") { _ti.Install(new Hashtable()); } else if (pArgs[0].ToLower() == "/uninstall") { _ti.Uninstall(null); } }
private static void Install(bool install, ServiceInfo serviceInfo) { using (TransactedInstaller transactedInstaller = new TransactedInstaller()) { using (Installer installer = CreateInstaller(serviceInfo)) { transactedInstaller.Installers.Add(installer); string path = string.Format("/assemblypath={0}", Assembly.GetEntryAssembly().Location); transactedInstaller.Context = new InstallContext("", new[] { path }); if (install) { transactedInstaller.Install(new Hashtable()); ServiceController service = new ServiceController(serviceInfo.ServiceName); if (service.Status != ServiceControllerStatus.Running && service.Status != ServiceControllerStatus.StartPending) { service.Start(); } return; } transactedInstaller.Uninstall(null); } } }
public static void UnInstallByServicePath(string servicePath) { try { string serviceName = GetServiceNameByPath(servicePath); if (ExistsService(serviceName)) { TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(servicePath, cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Uninstall(null); while (ExistsService(serviceName) == true) { break; } } else { throw new Exception("卸载的服务不存在"); } } catch (Exception) { throw; } }
internal static void uninstallService() { ServiceInstaller serviceInstaller = null; TransactedInstaller transactedInstaller = null; try { serviceInstaller = new ServiceInstaller(); serviceInstaller.ServiceName = "OpenVPNManager"; transactedInstaller = new TransactedInstaller(); transactedInstaller.Installers.Add(serviceInstaller); transactedInstaller.Uninstall(null); } catch (InstallException e) { if (e.InnerException != null && e.InnerException is SecurityException)// Probably: "Permission denied" { String MSG_ServiceInstallPermissionErrorAdvice = Program.res.GetString("MSG_ServiceInstallPermissionErrorAdvice"); MessageBox.Show("Error: " + e.InnerException.Message + "\r\n\r\n" + MSG_ServiceInstallPermissionErrorAdvice); } else if (e.InnerException != null && e.InnerException is Win32Exception)// Probably: "Service does not exist." { MessageBox.Show("Error: " + e.InnerException.Message); } else { throw; } } finally { serviceInstaller.Dispose(); transactedInstaller.Dispose(); } }
public void UnInstall() { string serviceFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GTaskService.exe"); if (!File.Exists(serviceFileName)) { Console.WriteLine("文件GTaskService.exe不存在!"); return; } try { string[] cmdline = { }; TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Uninstall(null); } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.Message.Contains("拒绝访问")) { Console.WriteLine("请右键“以管理员身份运行”!"); } else { Console.WriteLine(ex); } Console.WriteLine("\r\n~~~~~~~~~~服务卸载失败!~~~~~~~~~~"); } }
/// <summary> /// 配置服务 /// </summary> /// <param name="serviceName"></param> /// <param name="install"></param> public static void ConfigService(string serviceName, bool install) { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); ti.Installers.Add(new ServiceInstaller { DisplayName = serviceName, ServiceName = serviceName, Description = "上海秒优供应链管理有限公司消息推送服务", ServicesDependedOn = new string[] { "MSSQLSERVER" }, //前置服务 StartType = ServiceStartMode.Automatic //运行方式 }); ti.Context = new InstallContext(); ti.Context.Parameters["assemblypath"] = "\"" + Assembly.GetEntryAssembly().Location + "\" /service"; if (install) { ti.Install(new Hashtable()); } else { ti.Uninstall(null); } }
private static void Main(string[] args) { // Set up the crash dump handler. AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(unhandledException); cultureInfo = new System.Globalization.CultureInfo("en-GB"); settingsManager = new SettingsManager(); cloudFlareAPI = new CloudFlareAPI(); if (args.Length > 0) { if (args[0] == "/service") { runService(); return; } if (args[0] == "/install") { if (!isAdmin) { AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/ ); Console.WriteLine("Need to be running from an elevated (Administrator) command prompt."); FreeConsole(); return; } TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Install(new System.Collections.Hashtable()); ti.Dispose(); return; } if (args[0] == "/uninstall") { if (!isAdmin) { AttachConsole(-1 /*ATTACH_PARENT_PROCESS*/ ); Console.WriteLine("Need to be running from an elevated (Administrator) command prompt."); FreeConsole(); return; } TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(new ServiceInstaller()); ti.Context = new System.Configuration.Install.InstallContext("", null); ti.Context.Parameters["assemblypath"] = "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" /service"; ti.Uninstall(null); ti.Dispose(); return; } } runGUI(); return; }//end Main()
//----------------------------------- Private ------------------------------------------------- private void runService(string[] pArgs) { AppDomain.CurrentDomain.UnhandledException += onUnhandledException; EventLog.WriteEntry("Application", "RbrWinService.Start, Application level Exception handler installed...", EventLogEntryType.Information, 1); //-- check for arguments, if no arguments given, just run if (pArgs.Length == 0) { Run(new ServiceBase[1] { this }); return; } string _opt = pArgs[0]; try { if (_opt.ToLower() == "/install" || _opt.ToLower() == "/uninstall") { if (pArgs.Length != 2) { Console.WriteLine("Usage: appname /install (or /uninstall) version"); return; } //-- Create installers var _ti = new TransactedInstaller(); var _cmdLine = new string[1] { string.Format("/assemblypath={0}", Assembly.GetExecutingAssembly().Location) }; _ti.Context = new InstallContext(string.Empty, _cmdLine); _ti.Installers.Add(new RbrServiceInstaller(new[] { "MSSQL$TRBR", "SharedAccess", "Timok.Rbr." + pArgs[1] }, pArgs[1])); if (_opt.ToLower() == "/install") { _ti.Install(new Hashtable()); } else if (_opt.ToLower() == "/uninstall") { _ti.Uninstall(null); } } else if (_opt.ToLower() == "/console") { OnStart(args); Console.WriteLine("\r\nStarted... Press ENTER to stop."); Console.ReadLine(); Console.WriteLine("Stopping..."); OnStop(); } else { Console.WriteLine("Error, Valid Arguments are: /console, /install or /uninstall. Press any ENTER to finish..."); } } catch (Exception _ex) { Console.WriteLine("Timok.Rbr, Exception in [" + _opt + "] mode: " + _ex); } }
public void Uninstall() { using (var installer = new TransactedInstaller()) { SetInstallers(installer); installer.Uninstall(null); } }
private static void UnistallService(string path) { using (TransactedInstaller transacted = new TransactedInstaller()) { AssemblyInstaller installer = new AssemblyInstaller(path, new string[] { }); transacted.Installers.Add(installer); transacted.Uninstall(null); } }
/// <summary> /// Lance la désinstallation du service. /// </summary> /// <remarks><c>virtual void</c> afin de faciliter les tests unitaires.</remarks> /// <param name="serviceAssembly">Assembly du service. Faire <c>Assembly.GetExecutingAssembly()</c> pour l'obtenir.</param> public virtual void Uninstall(Assembly serviceAssembly) { using (var installer = new ServiceInstallerComponent(serviceAssembly)) using (var ti = new TransactedInstaller()) { ti.Installers.Add(installer); ti.Context = new InstallContext(logFilePath: null, commandLine: new string[] { "/assemblypath=" + installer.ServiceAssemblyPath }); ti.Uninstall(savedState: null); } }
public static void RuntimeUninstall(ElasticsearchServiceConfiguration configuration) { string path = "/assemblypath=" + configuration.ExeLocation; using (var ti = new TransactedInstaller()) { ti.Installers.Add(new ElasticsearchServiceInstaller(configuration)); ti.Context = new InstallContext(null, new[] { path }); ti.Uninstall(null); } }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); //CalculateAoLaiSubjectDiscountInfo.BLL.CalculationBLL.Run(); //Console.ReadLine(); // 同一进程中可以运行多个用户服务。若要将 // 另一个服务添加到此进程中,请更改下行以 // 创建另一个服务对象。例如, if (args.Length == 0) { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Calculation() }; ServiceBase.Run(ServicesToRun); } // 安装服务 else if (args[0].ToLower() == "/i" || args[0].ToLower() == "-i") { try { string[] cmdline = { }; string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location; TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Install(new System.Collections.Hashtable()); } catch (Exception ex) { string msg = ex.Message; } } // 删除服务 else if (args[0].ToLower() == "/u" || args[0].ToLower() == "-u") { try { string[] cmdline = { }; string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location; TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Uninstall(null); } catch (Exception ex) { string msg = ex.Message; } } }
public static void Uninstall() { var ti = new TransactedInstaller(); ti.Installers.Add(GetProjectInstaller()); ti.Context = new InstallContext("", null); var path = Assembly.GetExecutingAssembly().Location; ti.Context.Parameters["assemblypath"] = path; ti.Uninstall(null); }
public static void UninstallService() { var ti = new TransactedInstaller(); ti.Installers.Add(new ProjectInstaller()); ti.Context = new InstallContext("", null); string path = Application.ExecutablePath; ti.Context.Parameters["assemblypath"] = path; ti.Uninstall(null); }
/// <summary> /// Performs a transacted un-installation at run-time of the AutoCounterInstaller and any other listed installers. /// </summary> /// <param name="otherInstallers"> /// The other installers to include in the transaction /// </param> /// <typeparam name="T"> /// The IWindowsService implementer to install. /// </typeparam> public static void RuntimeUnInstall <T>(params Installer[] otherInstallers) where T : IWindowsService { string path = "/assemblypath=" + Assembly.GetEntryAssembly().Location; using (var ti = new TransactedInstaller()) { ti.Installers.Add(new WindowsServiceInstaller(typeof(T))); ti.Context = new InstallContext(null, new[] { path }); ti.Uninstall(null); } }
/// <summary> /// Uninstalls the Windows service with the given "installer" object. /// </summary> /// <param name="installer">The installer.</param> /// <param name="pathToService">The path to the service.</param> public static void UninstallService(Installer installer, string pathToService) { TransactedInstaller ti = new TransactedInstaller(); ti.Installers.Add(installer); string[] cmdline = { pathToService }; InstallContext ctx = new InstallContext("Uninstall.log", cmdline); ti.Context = ctx; ti.Uninstall(null); }
static void Main(string[] args)//string[] args { // 运行服务 if (args.Length == 0) { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new Servicesqlbackup() }; ServiceBase.Run(ServicesToRun); } // 安装服务 else if (args[0].ToLower() == "/i" || args[0].ToLower() == "-i") { try { string[] cmdline = { }; string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location; TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Install(new System.Collections.Hashtable()); } catch (Exception ex) { string msg = ex.Message; } } // 删除服务 else if (args[0].ToLower() == "/u" || args[0].ToLower() == "-u") { try { string[] cmdline = { }; string serviceFileName = System.Reflection.Assembly.GetExecutingAssembly().Location; TransactedInstaller transactedInstaller = new TransactedInstaller(); AssemblyInstaller assemblyInstaller = new AssemblyInstaller(serviceFileName, cmdline); transactedInstaller.Installers.Add(assemblyInstaller); transactedInstaller.Uninstall(null); } catch (Exception ex) { string msg = ex.Message; } } //以窗口方式运行服务 else if (args[0].ToLower() == "/f" || args[0].ToLower() == "-f" || args[0].ToLower() == "/form" || args[0].ToLower() == "-form") { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }
protected void Unregister() { using (var transactedInstall = new TransactedInstaller()) { transactedInstall.Installers.Add(Installer); if (ENTRY_ASSEMBLY != null) { transactedInstall.Context = new InstallContext(null, CommandLine); transactedInstall.Uninstall(null); } } }
public static void Install(string[] args) { bool flag = false; bool flag2 = false; TransactedInstaller installerWithHelp = new TransactedInstaller(); bool flag3 = false; try { ArrayList list = new ArrayList(); for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("/", StringComparison.Ordinal) || args[i].StartsWith("-", StringComparison.Ordinal)) { string strA = args[i].Substring(1); if ((string.Compare(strA, "u", StringComparison.OrdinalIgnoreCase) == 0) || (string.Compare(strA, "uninstall", StringComparison.OrdinalIgnoreCase) == 0)) { flag = true; } else if ((string.Compare(strA, "?", StringComparison.OrdinalIgnoreCase) == 0) || (string.Compare(strA, "help", StringComparison.OrdinalIgnoreCase) == 0)) { flag3 = true; } else if (string.Compare(strA, "AssemblyName", StringComparison.OrdinalIgnoreCase) == 0) { flag2 = true; } else { list.Add(args[i]); } } else { string name = args[i]; ServiceName = name; Assembly assembly = Assembly.GetExecutingAssembly(); AssemblyInstaller installer2 = new AssemblyInstaller(assembly, (string[])list.ToArray(typeof(string))); installerWithHelp.Installers.Add(installer2); } } if (flag3 || (installerWithHelp.Installers.Count == 0)) { flag3 = true; installerWithHelp.Installers.Add(new AssemblyInstaller()); throw new InvalidOperationException("GetHelp(installerWithHelp)"); } installerWithHelp.Context = new InstallContext("InstallUtil.InstallLog", (string[])list.ToArray(typeof(string))); } catch (Exception exception2) { if (flag3) { throw exception2; } throw new InvalidOperationException("InstallInitializeException"); } try { string str2 = installerWithHelp.Context.Parameters["installtype"]; if ((str2 != null) && (string.Compare(str2, "notransaction", StringComparison.OrdinalIgnoreCase) == 0)) { string str3 = installerWithHelp.Context.Parameters["action"]; if ((str3 != null) && (string.Compare(str3, "rollback", StringComparison.OrdinalIgnoreCase) == 0)) { installerWithHelp.Context.LogMessage("InstallRollbackNtRun"); for (int j = 0; j < installerWithHelp.Installers.Count; j++) { installerWithHelp.Installers[j].Rollback(null); } } else if ((str3 != null) && (string.Compare(str3, "commit", StringComparison.OrdinalIgnoreCase) == 0)) { installerWithHelp.Context.LogMessage("InstallCommitNtRun"); for (int k = 0; k < installerWithHelp.Installers.Count; k++) { installerWithHelp.Installers[k].Commit(null); } } else if ((str3 != null) && (string.Compare(str3, "uninstall", StringComparison.OrdinalIgnoreCase) == 0)) { installerWithHelp.Context.LogMessage("InstallUninstallNtRun"); for (int m = 0; m < installerWithHelp.Installers.Count; m++) { installerWithHelp.Installers[m].Uninstall(null); } } else { installerWithHelp.Context.LogMessage("InstallInstallNtRun"); for (int n = 0; n < installerWithHelp.Installers.Count; n++) { installerWithHelp.Installers[n].Install(null); } } } else if (!flag) { IDictionary stateSaver = new Hashtable(); installerWithHelp.Install(stateSaver); } else { installerWithHelp.Uninstall(null); } } catch (Exception exception3) { throw exception3; } }