Exemple #1
0
        private void action_ResetSusClientId(object sender, EventArgs e)
        {
            WSUSSettingManager wsmgr = new WSUSSettingManager(true);

            wsmgr.ResetSusClientId();
            ShowMessage("SusClientID regenerated.");
        }
Exemple #2
0
        private void ReadSettings(object sender, EventArgs e)
        {
            //read currentsettings without change reg
            WSUSSettingManager wsmgr = new WSUSSettingManager();

            txtWSUSServer.Text = wsmgr.WSUSServer;

            txtWSUSStateServer.Text         = wsmgr.WSUSStateServer;
            chkEnableGroup.Checked          = wsmgr.EnableGroupSettings;
            txtGroupName.Text               = wsmgr.ComputergroupName;
            chkEnableUpdateInterval.Checked = wsmgr.AutoUpdateDetection;

            int adu = wsmgr.AutoUpdateInterval;

            if (adu >= numUpdateInterval.Minimum && adu <= numUpdateInterval.Maximum)
            {
                numUpdateInterval.Value = adu;
            }

            chkEnableRebootDelay.Checked = wsmgr.RebootDelayEnabled;

            int rdl = wsmgr.RebootDelayTime;

            if (rdl >= numRebootDelayTime.Minimum && rdl <= numRebootDelayTime.Maximum)
            {
                numRebootDelayTime.Value = rdl;
            }

            chkAutoInstallMinor.Checked = wsmgr.AutoInstallMinorUpdates;
            chkNoRebootWithUser.Checked = !wsmgr.AllowRebootIfUserLoggedOn;
            chkNonAdminInstall.Checked  = wsmgr.AllowNonAdminInstall;
        }
Exemple #3
0
        private void action_removeWSUSRegKeys(object sender, EventArgs e)
        {
            //Are you sure etc.;
            if (MessageBox.Show("Are you sure you want to remove the WSUS settings?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                WSUSSettingManager wsmgr = new WSUSSettingManager(true);
                bool backupDone          = false;
                saveRegFile_Dialog.FileName = String.Format("{0}_{1}", System.Environment.MachineName, DateTime.Now.ToString("yyyy-MM-dd_HHmm"));
                if (saveRegFile_Dialog.ShowDialog() == DialogResult.OK)
                {
                    WSUSSettingManager.BackupCurrentSettings(saveRegFile_Dialog.FileName);
                    backupDone = true;
                }
                if (backupDone == false)
                {
                    //let the user overwrite the backup - flag
                    backupDone = (MessageBox.Show("Are you sure you want to remove the WSUS settings without backup?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes);
                }
                if (backupDone)
                {
                    WSUSSettingManager.RemoveWSUS();
                }

                // We then refresh the GUI from settings in the registry. The GUI will appear empty since
                // settings have been deleted
                ReadSettings(sender, e);
            }
        }
Exemple #4
0
        private void cmdWriteSettings_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to enable the WSUS settings?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    saveRegFile_Dialog.FileName = String.Format("{0}_{1}", System.Environment.MachineName, DateTime.Now.ToString("yyyy-MM-dd_HHmm"));
                    if (saveRegFile_Dialog.ShowDialog() == DialogResult.OK)
                    {
                        WSUSSettingManager.BackupCurrentSettings(saveRegFile_Dialog.FileName);
                    }//end if safefile

                    WSUSSettingManager man = new WSUSSettingManager(true);
                    Cursor = Cursors.WaitCursor;

                    man.WSUSServer                   = txtWSUSServer.Text;
                    man.WSUSStateServer              = txtWSUSStateServer.Text;
                    man.EnableGroupSettings          = chkEnableGroup.Checked;
                    man.ComputergroupName            = txtGroupName.Text;
                    man.DetectionFrequencyEnabled    = chkEnableUpdateInterval.Checked;
                    man.DetectionFrequency           = (int)numUpdateInterval.Value;
                    man.RebootRelaunchTimeoutEnabled = chkEnableRebootDelay.Checked;
                    man.RebootRelaunchTimeout        = (int)numRebootDelayTime.Value;
                    man.AutoInstallMinorUpdates      = chkAutoInstallMinor.Checked;
                    man.AllowRebootIfUserLoggedOn    = !chkNoRebootWithUser.Checked;
                    man.AllowNonAdminInstall         = chkNonAdminInstall.Checked;
                    if (comboBoxAUOptions.SelectedIndex != -1) // Only if a value is selected
                    {
                        man.AUOptions = ((KeyValuePair <int, string>)comboBoxAUOptions.SelectedItem).Key;
                    }
                    if (comboBoxScheduledInstallDay.SelectedItem != null)
                    {
                        man.ScheduledInstallDay = ((KeyValuePair <int, string>)comboBoxScheduledInstallDay.SelectedItem).Key;
                    }

                    man.ScheduledInstallTime        = (int)numScheduledInstallTime.Value;
                    man.DisableWindowsUpdateAccess  = chkDisableWindowsUpdateAccess.Checked;
                    man.AcceptTrustedPublisherCerts = chkAcceptTrustedPublisherCerts.Checked;
                    man.RebootWarningTimeoutEnabled = chkRebootWarningTimeout.Checked;
                    man.RebootWarningTimeout        = (int)numRebootWarningTimeout.Value;
                    man.RescheduleWaitTimeEnabled   = chkRescheduleWaitTime.Checked;
                    man.RescheduleWaitTime          = (int)numRescheduleWaitTime.Value;


                    //chkEnableAutoUpdate.Checked
                    WSUSSettingManager.ServiceRestart();
                    WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.detectnow);
                    ShowMessage("WSUS has been successfully configured.");
                }//end try
                catch (Exception ex)
                {
                    HandleError(ex);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }//end if really?
        }
Exemple #5
0
 private void action_WUServiceStart(object sender, EventArgs e)
 {
     try
     {
         WSUSSettingManager.ServiceStart();
         ShowMessage("Service started");
     }
     catch (Exception ex)
     {
         HandleError(ex);
     }
 }
Exemple #6
0
 private void action_ExportRegToFile(object sender, EventArgs e)
 {
     try
     {
         saveRegFile_Dialog.FileName = String.Format("{0}_{1}", System.Environment.MachineName, DateTime.Now.ToString("yyyy-MM-dd_HHmm"));
         if (saveRegFile_Dialog.ShowDialog() == DialogResult.OK)
         {
             WSUSSettingManager man = new WSUSSettingManager();
             WSUSSettingManager.BackupCurrentSettings(saveRegFile_Dialog.FileName);
         } //end if safefile
     }     //end try
     catch (Exception ex)
     {
         HandleError(ex);
     }
 }
Exemple #7
0
        private void cmdWriteSettings_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to enable the WSUS settings?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    saveRegFile_Dialog.FileName = String.Format("{0}_{1}", System.Environment.MachineName, DateTime.Now.ToString("yyyy-MM-dd_HHmm"));
                    if (saveRegFile_Dialog.ShowDialog() == DialogResult.OK)
                    {
                        WSUSSettingManager.BackupCurrentSettings(saveRegFile_Dialog.FileName);
                    }//end if safefile

                    WSUSSettingManager man = new WSUSSettingManager(true);
                    Cursor = Cursors.WaitCursor;

                    man.WSUSServer                = txtWSUSServer.Text;
                    man.WSUSStateServer           = txtWSUSStateServer.Text;
                    man.EnableGroupSettings       = chkEnableGroup.Checked;
                    man.ComputergroupName         = txtGroupName.Text;
                    man.AutoUpdateDetection       = chkEnableUpdateInterval.Checked;
                    man.AutoUpdateInterval        = (int)numUpdateInterval.Value;
                    man.RebootDelayEnabled        = chkEnableRebootDelay.Checked;
                    man.RebootDelayTime           = (int)numRebootDelayTime.Value;
                    man.AutoInstallMinorUpdates   = chkAutoInstallMinor.Checked;
                    man.AllowRebootIfUserLoggedOn = !chkNoRebootWithUser.Checked;
                    man.AllowNonAdminInstall      = chkNonAdminInstall.Checked;

                    //chkEnableAutoUpdate.Checked
                    WSUSSettingManager.ServiceRestart();
                    WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.detectnow);
                    ShowMessage("WSUS has been successfully configured.");
                }//end try
                catch (Exception ex)
                {
                    HandleError(ex);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }//end if really?
        }
Exemple #8
0
 private void action_ForceDetectUpdates(object sender, EventArgs e)
 {
     WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.detectnow);
 }
Exemple #9
0
 private void action_removeWSUSCoockie(object sender, EventArgs e)
 {
     WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.resetauthorization);
 }
Exemple #10
0
 private void action_SendReportToWSUS(object sender, EventArgs e)
 {
     WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.reportnow);
 }
Exemple #11
0
 private void action_ShowSystrayNotification(object sender, EventArgs e)
 {
     WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.DemoUI);
 }
Exemple #12
0
 private void action_ShowWindowsUpdate(object sender, EventArgs e)
 {
     WSUSSettingManager.StartWUAUCtl(WSUSSettingManager.eWUAUCtlCmd.ShowWindowsUpdate);
 }
Exemple #13
0
        private void ReadSettings(object sender, EventArgs e)
        {
            try
            {
                //read currentsettings without change reg
                WSUSSettingManager wsmgr = new WSUSSettingManager();
                txtWSUSServer.Text = wsmgr.WSUSServer;

                txtWSUSStateServer.Text         = wsmgr.WSUSStateServer;
                chkEnableGroup.Checked          = wsmgr.EnableGroupSettings;
                txtGroupName.Text               = wsmgr.ComputergroupName;
                chkEnableUpdateInterval.Checked = wsmgr.DetectionFrequencyEnabled;

                int adu = wsmgr.DetectionFrequency;
                if (adu >= numUpdateInterval.Minimum && adu <= numUpdateInterval.Maximum)
                {
                    numUpdateInterval.Value = adu;
                }

                chkEnableRebootDelay.Checked = wsmgr.RebootRelaunchTimeoutEnabled;

                int rdl = wsmgr.RebootRelaunchTimeout;
                if (rdl >= numRebootDelayTime.Minimum && rdl <= numRebootDelayTime.Maximum)
                {
                    numRebootDelayTime.Value = rdl;
                }

                chkAutoInstallMinor.Checked = wsmgr.AutoInstallMinorUpdates;
                chkNoRebootWithUser.Checked = !wsmgr.AllowRebootIfUserLoggedOn;
                chkNonAdminInstall.Checked  = wsmgr.AllowNonAdminInstall;

                int?auOptions = wsmgr.AUOptions;
                if (auOptions != null)
                {
                    selectKey(comboBoxAUOptions, wsmgr.AUOptions);
                }
                else
                {
                    comboBoxAUOptions.SelectedIndex = -1; // If no reg settings, we don't select any index by default
                }

                selectKey(comboBoxScheduledInstallDay, wsmgr.ScheduledInstallDay);

                comboBoxAUOptions_SelectedIndexChanged(sender, e); // We check what is selected in the combo box.
                selectKey(comboBoxScheduledInstallDay, wsmgr.ScheduledInstallDay);

                numScheduledInstallTime.Value = wsmgr.ScheduledInstallTime;

                chkDisableWindowsUpdateAccess.Checked  = wsmgr.DisableWindowsUpdateAccess;
                chkAcceptTrustedPublisherCerts.Checked = wsmgr.AcceptTrustedPublisherCerts;

                chkRebootWarningTimeout.Checked = wsmgr.RebootWarningTimeoutEnabled;
                numRebootWarningTimeout.Value   = wsmgr.RebootWarningTimeout;

                chkRescheduleWaitTime.Checked = wsmgr.RescheduleWaitTimeEnabled;
                numRescheduleWaitTime.Value   = wsmgr.RescheduleWaitTime;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                HandleError(ex);
            }
        }