예제 #1
0
파일: GPO.cs 프로젝트: zen0bit/wumgr
        static public void ConfigAU(AUOptions option, int day = -1, int time = -1)
        {
            try
            {
                var subKey = Registry.LocalMachine.CreateSubKey(mWuGPO + @"\AU", true);
                switch (option)
                {
                case AUOptions.Default:     //Automatic(default)
                    subKey.DeleteValue("NoAutoUpdate", false);
                    subKey.DeleteValue("AUOptions", false);
                    break;

                case AUOptions.Disabled:     //Disabled
                    subKey.SetValue("NoAutoUpdate", 1);
                    subKey.DeleteValue("AUOptions", false);
                    break;

                case AUOptions.Notification:     //Notification only
                    subKey.SetValue("NoAutoUpdate", 0);
                    subKey.SetValue("AUOptions", 2);
                    break;

                case AUOptions.Download:     //Download only
                    subKey.SetValue("NoAutoUpdate", 0);
                    subKey.SetValue("AUOptions", 3);
                    break;

                case AUOptions.Scheduled:     //Scheduled Installation
                    subKey.SetValue("NoAutoUpdate", 0);
                    subKey.SetValue("AUOptions", 4);
                    break;

                case AUOptions.ManagedByAdmin:     //Managed by Admin
                    subKey.SetValue("NoAutoUpdate", 0);
                    subKey.SetValue("AUOptions", 5);
                    break;
                }

                if (option == AUOptions.Scheduled)
                {
                    if (day != -1)
                    {
                        subKey.SetValue("ScheduledInstallDay", day);
                    }
                    if (time != -1)
                    {
                        subKey.SetValue("ScheduledInstallTime", time);
                    }
                }
                else
                {
                    subKey.DeleteValue("ScheduledInstallDay", false);
                    subKey.DeleteValue("ScheduledInstallTime", false);
                }
            }
            catch { }
        }
예제 #2
0
파일: GPO.cs 프로젝트: zen0bit/wumgr
        static public AUOptions GetAU(out int day, out int time)
        {
            AUOptions option = AUOptions.Default;

            try
            {
                var    subKey   = Registry.LocalMachine.OpenSubKey(mWuGPO + @"\AU", false);
                object value_no = subKey == null ? null : subKey.GetValue("NoAutoUpdate");
                if (value_no == null || (int)value_no == 0)
                {
                    object value_au = subKey == null ? null : subKey.GetValue("AUOptions");
                    switch (value_au == null ? 0 : (int)value_au)
                    {
                    case 0: option = AUOptions.Default; break;

                    case 2: option = AUOptions.Notification; break;

                    case 3: option = AUOptions.Download; break;

                    case 4: option = AUOptions.Scheduled; break;

                    case 5: option = AUOptions.ManagedByAdmin; break;
                    }
                }
                else
                {
                    option = AUOptions.Disabled;
                }

                object value_day = subKey.GetValue("ScheduledInstallDay");
                day = value_day != null ? (int)value_day : 0;
                object value_time = subKey.GetValue("ScheduledInstallTime");
                time = value_time != null ? (int)value_time : 0;
            }
            catch { day = 0; time = 0; }
            return(option);
        }