Jagat
2005-04-11 07:09:31 UTC
Hi,
I am trying to rename a local system using the following code. But it is throwing an exception "Invalid method parameters". Any help to solve the issue is highly appreciated.
try
{
ManagementClass mComputerSystem = new ManagementClass(
"Win32_ComputerSystem");
ManagementBaseObject outParams;
//ManagementObjectCollection objMOC = objMC.GetInstances();
ManagementBaseObject objNewComputerName = mComputerSystem.GetMethodParameters("Rename");
//foreach( outParams in
//objNewComputerName.
objNewComputerName["Name"] = txtCompName.Text;
objNewComputerName["UserName"] = txtUserID.Text;
objNewComputerName["Password"] = txtPwd.Text;
outParams = mComputerSystem.InvokeMethod("Rename", objNewComputerName, null);
//int val = Convert.ToInt32(outParams["ReturnValue"]);
}
catch(Exception ex)
{
MessageBox.Show("Unable to Set Computer Name: " + ex.Message);
}
Thanks in advance..
From http://www.developmentnow.com/g/33_0_0_0_0_0/dotnet-framework-wmi.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
I am trying to rename a local system using the following code. But it is throwing an exception "Invalid method parameters". Any help to solve the issue is highly appreciated.
try
{
ManagementClass mComputerSystem = new ManagementClass(
"Win32_ComputerSystem");
ManagementBaseObject outParams;
//ManagementObjectCollection objMOC = objMC.GetInstances();
ManagementBaseObject objNewComputerName = mComputerSystem.GetMethodParameters("Rename");
//foreach( outParams in
//objNewComputerName.
objNewComputerName["Name"] = txtCompName.Text;
objNewComputerName["UserName"] = txtUserID.Text;
objNewComputerName["Password"] = txtPwd.Text;
outParams = mComputerSystem.InvokeMethod("Rename", objNewComputerName, null);
//int val = Convert.ToInt32(outParams["ReturnValue"]);
}
catch(Exception ex)
{
MessageBox.Show("Unable to Set Computer Name: " + ex.Message);
}
Thanks in advance..
From http://www.developmentnow.com/g/33_0_0_0_0_0/dotnet-framework-wmi.htm
Posted via DevelopmentNow.com Groups
http://www.developmentnow.com