Beispiel #1
0
        internal FrmRebootCommand(List <ADComputer> targetComputers, string login, string password)
        {
            InitializeComponent();
            _wrongCrendentialsWatcher = new WrongCredentialsWatcher();
            _wrongCrendentialsWatcher.IsWrongCredentials            = false;
            _wrongCrendentialsWatcher.IsAbortRequested              = false;
            _wrongCrendentialsWatcher.ContinueWithFailedCredentials = false;

            _closing = false;

            _targetComputers = targetComputers;
            _login           = login;
            _password        = password;

            if (!String.IsNullOrEmpty(Properties.Settings.Default.PersonalizedRebootMessage))
            {
                txtBxMessage.Text = Properties.Settings.Default.PersonalizedRebootMessage;
            }

            localComputerName = Environment.MachineName;
            string domaineName = ADHelper.GetDomainName();

            if (!string.IsNullOrEmpty(domaineName) && !localComputerName.EndsWith(domaineName))
            {
                localComputerName += "." + domaineName;
            }
        }
Beispiel #2
0
 private void btnGetSusClientID_Click(object sender, EventArgs e)
 {
     Logger.EnteringMethod();
     _aborting           = false;
     prgBrSearch.Value   = 0;
     prgBrSearch.Maximum = dtGrdVResult.SelectedRows.Count;
     prgBrSearch.Refresh();
     ChangeUIAccess(false);
     _wrongCrendentialsWatcher = new WrongCredentialsWatcher();
     System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(StartQuerySusClientID));
     t.Start();
 }
Beispiel #3
0
        private void ctxMnuComputer_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            Logger.EnteringMethod();
            Credentials cred = Credentials.GetInstance();

            lblCredentials.Text = cred.CredentialNotice;
            Logger.Write(lblCredentials);

            List <ADComputer>  targetComputers = new List <ADComputer>();
            FrmRemoteExecution remoteExecution = new FrmRemoteExecution();

            Logger.Write(dtGrdVResult.SelectedRows.Count + " computers selected.");

            foreach (DataGridViewRow row in dtGrdVResult.SelectedRows)
            {
                Logger.Write("Selecting " + row.Cells[0].Value.ToString());
                targetComputers.Add((ADComputer)row.Cells[0].Value);
            }

            ctxMnuComputer.Hide();
            switch (e.ClickedItem.Name)
            {
            case "GetWsusClientID":
                btnGetSusClientID_Click(null, null);
                break;

            case "ResetWsusClientID":
                btnResetWsusClientID_Click(null, null);
                break;

            case "StartService":
                Logger.Write("Start Service");
                if (dtGrdVResult.SelectedRows.Count != 0)
                {
                    if (cred.InitializeCredential() == false)
                    {
                        return;
                    }
                }
                _aborting = false;
                ManageService("wuauserv", "StartService", cred.Login, cred.Password);
                break;

            case "StopService":
                Logger.Write("Stop Service");
                if (dtGrdVResult.SelectedRows.Count != 0)
                {
                    if (cred.InitializeCredential() == false)
                    {
                        return;
                    }
                }
                _aborting = false;
                ManageService("wuauserv", "StopService", cred.Login, cred.Password);
                break;

            case "RestartService":
                Logger.Write("Restart Service");
                if (dtGrdVResult.SelectedRows.Count != 0)
                {
                    if (cred.InitializeCredential() == false)
                    {
                        return;
                    }
                }
                _aborting = false;
                ManageService("wuauserv", "RestartService", cred.Login, cred.Password);
                break;

            case "QueryServiceStatus":
                Logger.Write("Querying Service Status");
                this.Cursor = Cursors.WaitCursor;
                _wrongCrendentialsWatcher = new WrongCredentialsWatcher();
                _aborting = false;
                GetWuAuServiceStatus();
                this.Cursor = Cursors.Default;
                break;

            case "ShowWindowsUpdateLog":
                Logger.Write("Show WindowsUPdateLog");
                if (cred.InitializeCredential() == false)
                {
                    return;
                }
                this.Cursor = Cursors.WaitCursor;
                ADComputer computer = new ADComputer(dtGrdVResult.SelectedRows[0].Cells["ComputerName"].Value.ToString());
                if (!chkBxDontPing.Checked && !computer.Ping((int)nupPingTimeout.Value))
                {
                    MessageBox.Show(resMan.GetString("ComputerUnreachable"));
                }
                else
                {
                    computer.OpenWindowsUpdateLog(cred.Login, cred.Password);
                }
                this.Cursor = Cursors.Default;
                break;

            case "SendDetectNow":
                Logger.Write("Send DetectNow");
                remoteExecution.Show(this);
                remoteExecution.SendDetectNow(targetComputers, cred.Login, cred.Password);
                break;

            case "SendReportNow":
                Logger.Write("Send ReportNow");
                remoteExecution.Show(this);
                remoteExecution.SendReportNow(targetComputers, cred.Login, cred.Password);
                break;

            case "SendRebootNow":
                Logger.Write("Send RebootNow");
                FrmRebootCommand rebootCommand = new FrmRebootCommand(targetComputers, cred.Login, cred.Password);
                rebootCommand.Show();
                break;

            default:
                Logger.Write("**** Unable to detect the command");
                break;
            }
        }