Exemplo n.º 1
0
        /// <summary>
        /// Attempts to install/register the executable
        /// with the Service Control Manager (SCM).
        /// </summary>
        static void installService()
        {
            // The installer will barf if the event source
            // is already defined.  So we need to clean
            // up our house.
            EventLogWriter elv = new EventLogWriter();

            if (elv.SourceExists() == true)
            {
                elv.RemoveSource();
            }

            string executable = Assembly.GetExecutingAssembly().Location;

            ManagedInstallerClass.InstallHelper(
                new string[] { executable }
                );

            // We should now have the event source.
            // Let's make sure
            if (elv.SourceExists() != true)
            {
                elv.CreateSource();
            }
        }