Пример #1
0
        /// <summary>
        /// 지정된 파일과 동일한 리소스를 반환
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public bool ExtractExecutable(string filename)
        {
            try
            {
                using (Stream input = this.GetResourceStream(filename))
                    using (Stream output = File.Create(Path.Combine(Directory.GetCurrentDirectory(), filename)))
                    {
                        GreyUtils.CopyStream(input, output);
                    }
            } catch (Exception) {
                return(false);
            }

            return(true);
        }
Пример #2
0
        public MainWindow()
        {
            InitializeComponent();
            GreyUtils.Default();
            GreyCommand.Default();
            InitializeCheckList();

            InitTimer           = new Timer();
            InitTimer.Interval  = 3000;
            InitTimer.Elapsed  += DoItNow;
            InitTimer.AutoReset = false;
            InitTimer.Start();

            //string value = GreyWnReg.GetRegistryValue("SOFTWARE\\Microsoft\\Internet Explorer", "svcUpdateVersion", GreyWnReg.Hive.LocalMachine);
            //MessageBox.Show(value);
            //value = GreyWnReg.GetRegistryValue("SOFTWARE\\Microsoft\\Internet Explorer", "svcKBNumber", GreyWnReg.Hive.LocalMachine);
            //MessageBox.Show(value);
            // SOFTWARE\AhnLab\ASPack\9.0\Option\AVMON\
            // HKEY_LOCAL_MACHINE\SOFTWARE\AhnLab\ASPack\9.0\ServiceStatus
            // 레지스트리의 값이 없는 경우도 평가에 넣어야 함
            //value = GreyWnReg.GetRegistryValue("SOFTWARE\\AhnLab\\ASPack\\9.0\\Option\\AVMON", "sysmonuse", GreyWnReg.Hive.LocalMachine);
            //MessageBox.Show(value);
            // 권한 상승 로직
            if (IsAdministrator() == false)
            {
                //https://stackoverflow.com/questions/133379/elevating-process-privilege-programmatically
                // Restart program and run as admin
                var exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
                ProcessStartInfo startInfo = new ProcessStartInfo(exeName);
                startInfo.Verb = "runas";
                System.Diagnostics.Process.Start(startInfo);
                Application.Current.Shutdown();
                return;
            }

            //var CheckList = ConfigurationManager.AppSettings["Title"];
            //GreyUtils.Instance.ExtractExecutable("CheckList.xml");
            //string[] arg = GreyCommand.GetCommandLine("util1");
            //GreyCommand.ExecutedCallback(Directory.GetCurrentDirectory(), arg[0], arg[1]);
            //string output = GreyCommand.GetOutputFile("util1");
            //var reports = GreyXML.GetXmlOutput(output);
            //MessageBox.Show(reports[0]["time"]);

            /*
             * XElement root = XElement.Load("CheckList.xml");
             *
             * IEnumerable<XElement> util = from el in root.Elements("Item")
             *                           where (string)el.Attribute("code") == "MA-001"
             *                           select el;
             * IEnumerable<XElement> util1 = from el in root.Descendants("util")
             *          where (string)el.Attribute("type") == "util1"
             *          select el;
             * //where (string)el.Attribute("type") == "util1"
             * //select el;
             *
             * foreach(XElement el in util)
             * {
             *  MessageBox.Show((string)el.Attribute("title"));
             *  MessageBox.Show((string)el.Attribute("code"));
             *
             * }
             * // 명령어 옵션 추출
             * foreach (var el in util1)
             * {
             *  MessageBox.Show(string.Join(" ", (from xl in el.Elements("param")
             *                                    select (string)xl.Attribute("value"))));
             * }
             *
             * /*
             * XElement root = XElement.Load("PurchaseOrders.xml");
             * IEnumerable<XElement> purchaseOrders =
             *  from el in root.Elements("PurchaseOrder")
             *  where
             *      (from add in el.Elements("Address")
             *      where
             *          (string)add.Attribute("Type") == "Shipping" &&
             *          (string)add.Element("State") == "NY"
             *      select add)
             *      .Any()
             *  select el;
             * foreach (XElement el in purchaseOrders)
             *  Console.WriteLine((string)el.Attribute("PurchaseOrderNumber"));
             *
             */
            //GreyUtils.Instance.ExtractExecutable("lastactivityview.exe");
            //DiagnosticCheckList.ItemsSource = new List<String>{"fy","sadf" };
        }
Пример #3
0
 public static void Default()
 {
     GreyUtils.Instance = new GreyUtils();
 }