Exemple #1
0
        /// <summary>
        /// Creates a new object that is a deep copy of the current instance.
        /// </summary>
        /// <returns>A new object that is a deep copy of this instance.</returns>
        public object Clone()
        {
            WindowsServiceSetup result = new WindowsServiceSetup();

            result.Account                     = this.Account;
            result.AutoLog                     = this.AutoLog;
            result.CanHandlePowerEvent         = this.CanHandlePowerEvent;
            result.CanHandleSessionChangeEvent = this.CanHandleSessionChangeEvent;
            result.CanPauseAndContinue         = this.CanPauseAndContinue;
            result.CanShutdown                 = this.CanShutdown;
            result.CanStop                     = this.CanStop;
            result.Description                 = this.Description;
            result.DisplayName                 = this.DisplayName;
            result.Password                    = this.Password;
            result.RestartOnFailure            = this.RestartOnFailure;
            result.ServiceAssemblyPath         = this.ServiceAssemblyPath;
            result.ServiceName                 = this.ServiceName;
            result.ServicesDependedOn          = this.ServicesDependedOn;
            result.StartAfterInstall           = this.StartAfterInstall;
            result.StartType                   = this.StartType;
            result.Username                    = this.Username;
            result.WorkingDirectory            = this.WorkingDirectory;

            return(result);
        }
 /// <summary>
 /// Method Run.
 /// </summary>
 /// <param name="windowsService">IWindowsService instance.</param>
 /// <param name="isConsoleMode">true to start in console mode; otherwise, start in windows service mode.</param>
 /// <param name="args">Command line arguments.</param>
 public void Run(IWindowsService windowsService, bool isConsoleMode, string[] args)
 {
     this._windowsService = windowsService;
     this.IsConsoleMode   = isConsoleMode;
     this._args           = args;
     this._consoleStatus  = ServiceControllerStatus.Stopped;
     this._setupInfo      = windowsService.ServiceSetupInfo.Clone() as WindowsServiceSetup;
     this.RunWindowsServiceConsole();
 }
        /// <summary>
        /// Uninstall a windows service at runtime.
        /// </summary>
        /// <param name="windowsServiceSetup">Instance of WindowsServiceSetup.</param>
        public static void RuntimeUninstall(WindowsServiceSetup windowsServiceSetup)
        {
            TransactedInstaller transactedInstaller = null;

            try
            {
                transactedInstaller = new TransactedInstaller();
                transactedInstaller.Installers.Add(new WindowsServiceInstaller(windowsServiceSetup));
                transactedInstaller.Context = new InstallContext(null, new[] { string.Format("/assemblypath=\"{0}\"", windowsServiceSetup.ServiceAssemblyPath) });
                transactedInstaller.Uninstall(null);
            }
            catch (Exception e)
            {
                InternalLogger.Log(e);
            }
            finally
            {
                if (transactedInstaller != null)
                {
                    transactedInstaller.Dispose();
                    transactedInstaller = null;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WindowsServiceInstaller" /> class.
 /// </summary>
 /// <param name="windowsServiceSetup">Instance of WindowsServiceSetup.</param>
 public WindowsServiceInstaller(WindowsServiceSetup windowsServiceSetup)
 {
     this.InstallerSetupInfo = windowsServiceSetup;
     this.InitializeInstaller();
     this.Committed += this.OnWindowsServiceInstallerCommitted;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WindowsServiceInstaller" /> class.
 /// </summary>
 /// <param name="windowsServiceSetup">Instance of WindowsServiceSetup.</param>
 public WindowsServiceInstaller(WindowsServiceSetup windowsServiceSetup)
 {
     this.InstallerSetupInfo = windowsServiceSetup;
     this.InitInstaller();
 }