// Creates a new instance of the class
        // and adds it to 'Trace.Listeners'
        public static void Initialize(string name)
        {
            Directory.CreateDirectory(Application.CommonAppDataPath);

            TextWriterTraceListener tlog = new TimeDateTraceListener(
                Path.Combine(
                    Application.CommonAppDataPath,
                    name + ".log"),
                name + "Log"
            );
            Trace.Listeners.Add(tlog);
            Trace.AutoFlush = true;
        }
Пример #2
0
        public static void Initialize(string name)
        // Creates a new instance of the class
        // and adds it to 'Trace.Listeners'
        {
            Directory.CreateDirectory(Application.CommonAppDataPath);

            TextWriterTraceListener tlog = new TimeDateTraceListener(
                Path.Combine(
                    Application.CommonAppDataPath,
                    name + ".log"),
                name + "Log"
                );

            Trace.Listeners.Add(tlog);
            Trace.AutoFlush = true;
        }
Пример #3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            try
            {
                TimeDateTraceListener.Initialize("InstallAgent");

                if (args.Length == 0) // run as service
                {
                    // rebootOption is populated in the constructor
                    ServiceBase[] ServicesToRun;
                    ServicesToRun = new ServiceBase[]
                    {
                        new InstallAgent()
                    };
                    ServiceBase.Run(ServicesToRun);
                }
                else if (args.Length == 1) // run from command line
                {
                    InstallAgent.RebootType rebootOpt;

                    try
                    {
                        rebootOpt = (InstallAgent.RebootType)Enum.Parse(
                            typeof(InstallAgent.RebootType), args[0], true
                            );
                    }
                    catch
                    {
                        Usage();
                        return;
                    }

                    InstallAgent ias = new InstallAgent(rebootOpt);
                    ias.InstallThreadHandler();
                }
                else
                {
                    Usage();
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                throw;
            }
        }