public void AutoDisable()
 {
     string[] enabledList;
     string[] enabledMouseList;
     string[] enabledKeyboardList;
     Task.Factory.StartNew(() =>
     {
         while (true)
         {
             commonSet.LoadConfiguration();
             // get the list of all enabled device
             enabledList = cmd.ProcessResult(cmd.RunCommand("powercfg -devicequery wake_armed", 1));
             if (commonSet.loadedAutoDisableAll.ToLower().Equals("true"))
             {
                 // disable all the enabled devices
                 for (int i = 0; i < enabledList.Length; i++)
                 {
                     cmd.RunCommand("powercfg -devicedisablewake \"" + enabledList[i] + "\"", 1);
                 }
             }
             // check for mouse and keyboard disable
             else
             {
                 if (commonSet.loadedAutoDisableMouse.ToLower().Equals("true"))
                 {
                     // get the list of all enabled mouse
                     enabledMouseList = commonSet.GetStringsWithWord(enabledList, "mouse");
                     // disable all the enabled mouses
                     for (int i = 0; i < enabledMouseList.Length; i++)
                     {
                         cmd.RunCommand("powercfg -devicedisablewake \"" + enabledMouseList[i] + "\"", 1);
                     }
                 }
                 if (commonSet.loadedAutoDisableKeyboard.ToLower().Equals("true"))
                 {
                     // get the list of all enabled mouse
                     enabledKeyboardList = commonSet.GetStringsWithWord(enabledList, "keyboard");
                     // disable all the enabled keyboard
                     for (int i = 0; i < enabledKeyboardList.Length; i++)
                     {
                         cmd.RunCommand("powercfg -devicedisablewake \"" + enabledKeyboardList[i] + "\"", 1);
                     }
                 }
             }
             Thread.Sleep(10000);
         }
     });
 }
        private void GetDeviceList()
        {
            String[] result;
            if (CurrentDeviceRadioButton.IsChecked == true)
            {
                result = cmd.ProcessResult(cmd.RunCommandWithLoadingMessage("powercfg -devicequery wake_armed"));
            }
            else if (AllDeviceRadioButton.IsChecked == true)
            {
                result = cmd.ProcessResult(cmd.RunCommandWithLoadingMessage("powercfg -devicequery wake_programmable"));
            }
            else if (MouseDeviceRadioButton.IsChecked == true)
            {
                result = cmd.ProcessResult(cmd.RunCommandWithLoadingMessage("powercfg -devicequery wake_programmable"));
                result = commonSet.GetStringsWithWord(result, "mouse");
            }
            // it is the case of keyboard radio button is checked
            else
            {
                result = cmd.ProcessResult(cmd.RunCommandWithLoadingMessage("powercfg -devicequery wake_programmable"));
                result = commonSet.GetStringsWithWord(result, "keyboard");
            }

            // Get the device status
            String[] enabledDeviceList = cmd.ProcessResult(cmd.RunCommandWithLoadingMessage("powercfg -devicequery wake_armed"));
            String[] deviceStatusList  = GetDevicesStatus(enabledDeviceList, result);

            // put the result into check box
            resultSize = result.Length;
            String checkBoxName;

            for (int i = 0; i < result.Length; i++)
            {
                CheckBox cb = new CheckBox();
                cb.Content = result[i] + deviceStatusList[i];
                // set the name of the checkbox
                checkBoxName = "cb" + i;
                this.RegisterName(checkBoxName, cb);
                cb.Height = 40;
                // center the checkbox
                cb.VerticalAlignment = VerticalAlignment.Center;
                // add the check box into the list
                PossibleWakeUpDeviceList.Items.Add(cb);
            }
        }