Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Go to http://aka.ms/dotnet-get-started-console to continue learning how to build a console app!
            if (args.Length == 0 || (args.Length >= 1 && HelpRequired(args[0])))
            {
                // if displaying help.
                AppConsole.DisplayHelp();
            }
            else
            {
                // if running the code.
                string phpDir    = "";
                string apacheDir = "";
                if (args.Length >= 2)
                {
                    // if php versions folder was specified.
                    // set php folder path.
                    phpDir = args[1];
                }
                if (args.Length >= 3)
                {
                    // if apache folder was specified.
                    // set apache folder path.
                    apacheDir = args[2];
                }
                FileSystem Fs = new FileSystem(args[0], phpDir, apacheDir);

                // check that this is running as admin.
                if (IsRunAsAdmin() == false)
                {
                    // if not run as admin.
                    try
                    {
                        RelaunchAsAdmin();
                    } catch
                    {
                        AppConsole.ErrorMessage("Please run this command as administrator privilege.");
                        System.Threading.Thread.Sleep(5000);
                        Environment.Exit(1);
                    }
                }
                // end check if running as admin.

                // validate required folders.
                FileSystem.ValidateRequiredPath();

                // stop web server service.
                Service.StopWebServerService();

                // copy files (also remove running version before copy).
                FileSystem.StartCopyFiles();

                // start web server service again.
                Service.StartWebServerService();

                // success message and exit.
                AppConsole.SuccessExit();
            }
        }