コード例 #1
0
ファイル: Program.cs プロジェクト: kostaslamda/win-installer
        /// <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;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: xcp-ng/win-installer
        /// <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;
            }
        }