protected override void OnStart(string[] args)
        {
            try
            {
                base.OnStart(args);
            }
            catch (Exception) { };

            ApplicationLog.CreateSource();

            this.OpenNamedPipeServiceHost();

            if (Settings.AllowRemoteRequests)
            {
                this.OpenTcpServiceHost();
            }

            this.removalTimer.Start();
        }
        /// <summary>
        /// Handles the startup of the service.
        /// </summary>
        /// <param name="args">
        /// Data passed the start command.
        /// </param>
        /// <remarks>
        /// This function executes when a Start command is sent to the service by the
        /// Service Control Manager (SCM) or when the operating system starts
        /// (for a service that starts automatically).
        /// </remarks>
        protected override void OnStart(string[] args)
        {
            try
            {
                base.OnStart(args);
            }
            catch (Exception) { };

            // Create the Windows Event Log source for this application.
            ApplicationLog.CreateSource();

            // Open the service host which is accessible via named pipes.
            this.OpenNamedPipeServiceHost();

            // If remote requests are allowed, open the service host which
            // is accessible via TCP.
            if (Settings.AllowRemoteRequests)
            {
                try
                {
                    this.OpenTcpServiceHost();
                }
                catch (AddressAlreadyInUseException addressInUseException)
                {
                    System.Text.StringBuilder logMessage = new System.Text.StringBuilder(addressInUseException.Message);
                    logMessage.Append(System.Environment.NewLine);
                    logMessage.Append(string.Format("Determine whether another application is using TCP port {0:N0}.", Settings.TCPServicePort));
                    ApplicationLog.WriteEvent(logMessage.ToString(), EventID.RemoteAccessFailure, System.Diagnostics.EventLogEntryType.Warning);
                }
                catch (Exception)
                {
                    ApplicationLog.WriteEvent("Unhandled exception while opening the remote request handler. Remote requests may not be honored.", EventID.RemoteAccessFailure, System.Diagnostics.EventLogEntryType.Warning);
                }
            }

            if ((Settings.LogElevatedProcesses != ElevatedProcessLogging.Never) && (this.processWatchSession == null))
            {
                StartTracing();
            }

            // Start the timer that watches for expired administrator rights.
            this.removalTimer.Start();
        }
Beispiel #3
0
        /// <summary>
        /// Handles the startup of the service.
        /// </summary>
        /// <param name="args">
        /// Data passed the start command.
        /// </param>
        /// <remarks>
        /// This function executes when a Start command is sent to the service by the
        /// Service Control Manager (SCM) or when the operating system starts
        /// (for a service that starts automatically).
        /// </remarks>
        protected override void OnStart(string[] args)
        {
            try
            {
                base.OnStart(args);
            }
            catch (Exception) { };

            // Create the Windows Event Log source for this application.
            ApplicationLog.CreateSource();

            // Open the service host which is accessible via named pipes.
            this.OpenNamedPipeServiceHost();

            // If remote requests are allowed, open the service host which
            // is accessible via TCP.
            if (Settings.AllowRemoteRequests)
            {
                this.OpenTcpServiceHost();
            }

            // Start the timer that watches for expired administrator rights.
            this.removalTimer.Start();
        }