Ejemplo n.º 1
0
        public static OptionSet configParse(string configPath)
        {
            //Parser method - gets properties values from config.xml
            OptionSet result = new OptionSet();
            XmlDocument config = new XmlDocument();

            config.Load(configPath);
            XmlNode node = config.DocumentElement.SelectSingleNode("/config/domainEnvironment");
            result.domainEnv = Convert.ToBoolean(node.InnerText);
            node = config.DocumentElement.SelectSingleNode("/config/userName");
            result.userName = node.InnerText;
            node = config.DocumentElement.SelectSingleNode("/config/groupName");
            result.groupName = node.InnerText;
            node = config.DocumentElement.SelectSingleNode("/config/reportPath");
            result.reportPath = node.InnerText;
            node = config.DocumentElement.SelectSingleNode("/config/state");
            result.state = Convert.ToInt16(node.InnerText);
            result.cPath = Program._args[0].ToString();
            //Creating report XML
            if (!File.Exists(result.reportPath))
            {
                using (XmlWriter writer = XmlWriter.Create(result.reportPath))
                {
                    writer.WriteStartElement("Report");
                    writer.WriteEndElement();
                    writer.Flush();
                }
                XmlDocument report = new XmlDocument();
                report.Load(result.reportPath);
                XmlNode node2 = report.DocumentElement.SelectSingleNode("/Report");
                XmlElement xHistory = report.CreateElement("History");
                node2.AppendChild(xHistory);
                XmlElement xReboots = report.CreateElement("Reboots");
                node2.AppendChild(xReboots);
                XmlElement xResults = report.CreateElement("Results");
                node2.AppendChild(xResults);
                report.Save(result.reportPath);
            }
            return result;
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            #region Variable setup
            //Setting up all neccessary variables
            _systemDrive = Path.GetPathRoot(Environment.SystemDirectory);
            _batchPath = _systemDrive + "Windows\\System32\\GroupPolicy\\Machine\\Scripts\\Startup\\RenewAdmin.bat";
            _scriptPath = _systemDrive + "Windows\\System32\\GroupPolicy\\Machine\\Scripts\\scripts.ini";
            _gptPath = _systemDrive + "Windows\\System32\\GroupPolicy\\gpt.ini";
            _updateCmd = _systemDrive + "Program Files\\NCR Aptra\\Advance NDC\\Customisations.PL\\System\\Update\\update2.cmd";
            _args = args;
            #endregion

            //_Config parse, setting up the initial object
            _Config = OptionSet.configParse(args[0].ToString());
            _Config.LogHistory( 999, "Start. Checking state.");
            _Config.LogHistory(_Config.state, "Running state: " + _Config.state.ToString());

            //Main if - determine actions
            if (_Config.state == 0)
            { prep(); }
            else if (_Config.state == 1)
            { execution(); }
            else if (_Config.state == 2)
            { cleanup(); }
        }