Discussion:
Urgent: Win32_ComputerSystem and Rename method in C#
(too old to reply)
Jagat
2005-04-11 07:09:31 UTC
Permalink
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
Willy Denoyette [MVP]
2005-04-11 09:23:09 UTC
Permalink
Post by Jagat
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
You cannot specify a username and password when renaming a local system.

Willy.
Shakil
2008-11-19 10:13:23 UTC
Permalink
If you got the solution of your problem, please send me your code. My mail id ***@yahoo.com

From http://www.developmentnow.com/g/33_2005_4_0_0_498202/Urgent-Win32-ComputerSystem-and-Rename-method-in-C.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...