Beispiel #1
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);
            }
        }
Beispiel #2
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?
        }
Beispiel #3
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);
     }
 }
Beispiel #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.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?
        }