try

{

ConnectionOptions connection = new ConnectionOptions();

connection.Username = userNameBox.Text;

connection.Password = passwordBox.Text;

connection.Authority = "ntlmdomain:Finance123";

ManagementScope scope = new ManagementScope(

"\\dell417\root\CIMV2", connection);

scope.Connect();

ObjectQuery query= new ObjectQuery(

"SELECT * FROM Win32_BootConfiguration");

ManagementObjectSearcher searcher =

new ManagementObjectSearcher(scope, query);

foreach (ManagementObject queryObj in searcher.Get())

{

Console.WriteLine("");

Console.WriteLine("Win32_BootConfiguration instance");

Console.WriteLine("");

Console.WriteLine("BootDirectory: {0}", queryObj["BootDirectory"]);

Console.WriteLine("Caption: {0}", queryObj["Caption"]);

Console.WriteLine("ConfigurationPath: {0}", queryObj["ConfigurationPath"]);

Console.WriteLine("Description: {0}", queryObj["Description"]);

Console.WriteLine("LastDrive: {0}", queryObj["LastDrive"]);

Console.WriteLine("Name: {0}", queryObj["Name"]);

Console.WriteLine("ScratchDirectory: {0}", queryObj["ScratchDirectory"]);

Console.WriteLine("SettingID: {0}", queryObj["SettingID"]);

Console.WriteLine("TempDirectory: {0}", queryObj["TempDirectory"]);

}

Close();

}

catch(ManagementException err)

{

MessageBox.Show("An error occurred while querying for WMI data: " + err.Message);

}

catch(System.UnauthorizedAccessException unauthorizedErr)

{

MessageBox.Show("Connection error (user name or password might be incorrect): " + unauthorizedErr.Message);

}

Advertisements