I have this bit of code
The problem I am having though is that it takes for ever to run. Assuming I have 3000 executables I believe this code will hit the remote machine 3000 different times to get 1 set of information and then moving on to the next.
So my question is, how do I grab all of the data at once and then iterate through the list on my own box? I want to connect once, grab the info and display the results using as little network as possable.
tia
Code:
int counter = 0;
ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"\\" + strComputerName + @"\root\CIMV2", "SELECT * FROM CIM_DataFile where Extension = 'exe'");
foreach (ManagementObject queryObj in searcher.Get())
{
this.txtMessageBox.Text = this.txtMessageBox.Text + counter.ToString() + "CIM_DataFile instance" + " ";
this.txtMessageBox.Text = this.txtMessageBox.Text + "CreationDate:" + queryObj["CreationDate"].ToString() + " ";
this.txtMessageBox.Text = this.txtMessageBox.Text + "Caption:" + queryObj["Caption"].ToString() + " ";
this.txtMessageBox.Text = this.txtMessageBox.Text + "CSName:" + queryObj["CSName"].ToString() + " ";
this.txtMessageBox.Text = this.txtMessageBox.Text + "FileName:" + queryObj["FileName"].ToString() + " ";
try
{
this.txtMessageBox.Text = this.txtMessageBox.Text + "Manufacturer:" + queryObj["Manufacturer"].ToString() + " ";
}
catch
{
this.txtMessageBox.Text = this.txtMessageBox.Text + "Manufacturer:NULL ";
}
this.txtMessageBox.Text = this.txtMessageBox.Text + "LastAccessed:" + queryObj["LastAccessed"].ToString() + "\r\n";
counter++;
}
The problem I am having though is that it takes for ever to run. Assuming I have 3000 executables I believe this code will hit the remote machine 3000 different times to get 1 set of information and then moving on to the next.
So my question is, how do I grab all of the data at once and then iterate through the list on my own box? I want to connect once, grab the info and display the results using as little network as possable.
tia