private void mNamespaceSelector_Click(object sender, EventArgs e) { WmiQueryTool = new WmiInformationGatherer("localhost"); mNamespaceSelector.Items.Clear(); foreach (string Namespace in WmiQueryTool.WmiResults.Namespaces) { mNamespaceSelector.Items.Add(Namespace); } WmiQueryTool = null; }
private void FireError(string pHost) { string error = "Something went wrong"; switch (WmiQueryTool.WmiResults.WmiError.HResult) { case -2147023174: error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nThe remote host is likely offline or having issues. Check remote IP and try again"; WmiQueryTool = null; ScavengeStatus(pHost, false); break; case -2147023838: error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nThe Remote host appears to not be WMI capable. This can be caused by the WMI service being disabled, or the remote host not being a Windows system. Please validate remote host settings and try again"; WmiQueryTool = null; ScavengeStatus(pHost, false); break; case -2147024891: error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nYour currently logged on user does not appear to have rights on the remote system. Please check your rights and try again. Your user may need to be added to the RDP group first"; WmiQueryTool = null; ScavengeStatus(pHost, false); break; default: error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nSomething went horribly wrong. There's an error code here. Report it to the developer, along with what you were doing so he can replicate the issue"; break; } if (mResultsForm == null) { mResultsForm = new Form(); mResultsForm.FormClosed += mResultsForm_FormClosed; resultsTextBox = new TextBox(); mResultsForm.Width = 615; mResultsForm.Height = 433; mResultsForm.Controls.Add(resultsTextBox); mResultsForm.Text = "Error Window"; mResultsForm.MaximumSize = new Size(615, 433); mResultsForm.MinimumSize = new Size(615, 433); mResultsForm.SetDesktopLocation(0, 0); resultsTextBox.Location = new Point(0, 0); resultsTextBox.Size = new Size(600, 399); resultsTextBox.Multiline = true; resultsTextBox.ScrollBars = ScrollBars.Vertical; resultsTextBox.Visible = true; resultsTextBox.Enabled = true; resultsTextBox.AppendText(error + "\r\n\r\n"); } else { resultsTextBox.AppendText(error + "\r\n\r\n"); } }
private void mScavengedNSResultTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Parent == null) { return; } else { WmiQueryTool = new WmiInformationGatherer(e.Node.Text, e.Node.Parent.Text, true); mScavengedClassesTreeView.Nodes.Clear(); mScavengedClassesTreeView.Nodes.Add(WmiQueryTool.WmiResults.ConnectedHost); for (int i = 0; i < WmiQueryTool.WmiResults.Classes.Count; i++) { mScavengedClassesTreeView.Nodes[0].Nodes.Add(WmiQueryTool.WmiResults.Classes[i]); } mScavengedClassesTreeView.Nodes[0].Expand(); } }
private void mScavengeButton_Click(object sender, EventArgs e) { if (!CheckForValidState(false)) { return; } string[] computerNames = mComputerNameTextBox.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (WmiQueryTool == null || computerNames.Length != lastScavengeCount) { lastScavengeCount = computerNames.Length; mScavengedNSResultTreeView.Nodes.Clear(); for (int i = 0; i < computerNames.Length; i++) { mPreviousHostScavenged = computerNames[i]; WmiQueryTool = new WmiInformationGatherer(computerNames[i]); if (WmiQueryTool.WmiResults.WmiError != null) { FireError(computerNames[i]); mScavengedNSResultTreeView.Nodes.Add(computerNames[i]); mScavengedNSResultTreeView.Nodes[i].BackColor = Color.Red; continue; } else { mScavengedNSResultTreeView.Nodes.Add(computerNames[i]); foreach (string Namespace in WmiQueryTool.WmiResults.Namespaces) { mScavengedNSResultTreeView.Nodes[i].Nodes.Add(Namespace); } ScavengeStatus(WmiQueryTool.WmiResults.ConnectedHost, true); WmiQueryTool = null; } } } }
private void mScavengeButton_Click(object sender, EventArgs e) { if (!CheckForValidState(false)) return; string[] computerNames = mComputerNameTextBox.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (WmiQueryTool == null || computerNames.Length != lastScavengeCount) { lastScavengeCount = computerNames.Length; mScavengedNSResultTreeView.Nodes.Clear(); for (int i = 0; i < computerNames.Length; i++) { mPreviousHostScavenged = computerNames[i]; WmiQueryTool = new WmiInformationGatherer(computerNames[i]); if (WmiQueryTool.WmiResults.WmiError != null) { FireError(computerNames[i]); mScavengedNSResultTreeView.Nodes.Add(computerNames[i]); mScavengedNSResultTreeView.Nodes[i].BackColor = Color.Red; continue; } else { mScavengedNSResultTreeView.Nodes.Add(computerNames[i]); foreach (string Namespace in WmiQueryTool.WmiResults.Namespaces) { mScavengedNSResultTreeView.Nodes[i].Nodes.Add(Namespace); } ScavengeStatus(WmiQueryTool.WmiResults.ConnectedHost, true); WmiQueryTool = null; } } } }