473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

exception of type 'System.Management.ManagementException'

Hi,
I need urgent help, this is my code to rename my hostName: (MY computer is
not member of domain)
string compName =
System.Windows.Forms.SystemInformation.ComputerNam e.ToString();
WqlObjectQuery query = new WqlObjectQuery("SELECT * FROM
Win32_ComputerSystem");
ManagementObjectSearcher search = new ManagementObjectSearcher(query);
object[] name = {"NewName"};
foreach (ManagementObject mo in search.Get())
{
mo.InvokeMethod("Rename", name);
}

This ex. appears everytime I run my application!

An unhandled exception of type 'System.Management.ManagementException'
occurred in system.management.dll

Additional information: This method is not implemented in any class

thanks in adv.
--
LZ
May 8 '06 #1
2 5450

"Lamis" <La***@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
| Hi,
| I need urgent help, this is my code to rename my hostName: (MY computer is
| not member of domain)
|
|
| string compName =
| System.Windows.Forms.SystemInformation.ComputerNam e.ToString();
| WqlObjectQuery query = new WqlObjectQuery("SELECT * FROM
| Win32_ComputerSystem");
| ManagementObjectSearcher search = new ManagementObjectSearcher(query);
| object[] name = {"NewName"};
| foreach (ManagementObject mo in search.Get())
| {
| mo.InvokeMethod("Rename", name);
| }
|
| This ex. appears everytime I run my application!
|
| An unhandled exception of type 'System.Management.ManagementException'
| occurred in system.management.dll
|
| Additional information: This method is not implemented in any class
|
| thanks in adv.
| --
| LZ

Note that this only works on XP or W2K3 or higher.

using (ManagementObject dir= new
ManagementObject("Win32_Computersystem.name='" + Environment.MachineName +
"'"))
{
ManagementBaseObject inputArgs = dir.GetMethodParameters("Rename");
inputArgs["Name"] = "NewName";
ManagementBaseObject outParams = dir.InvokeMethod("Rename", inputArgs,
null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret == 0)
// OK
else
// Failed
}

Willy.

May 8 '06 #2
Hi Willy,,

Yes I noticed.. I have win2000 installed on the machine but it works
perfectly on other machines with XP installed.

Thank you for helping
--
LZ
"Willy Denoyette [MVP]" wrote:

"Lamis" <La***@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
| Hi,
| I need urgent help, this is my code to rename my hostName: (MY computer is
| not member of domain)
|
|
| string compName =
| System.Windows.Forms.SystemInformation.ComputerNam e.ToString();
| WqlObjectQuery query = new WqlObjectQuery("SELECT * FROM
| Win32_ComputerSystem");
| ManagementObjectSearcher search = new ManagementObjectSearcher(query);
| object[] name = {"NewName"};
| foreach (ManagementObject mo in search.Get())
| {
| mo.InvokeMethod("Rename", name);
| }
|
| This ex. appears everytime I run my application!
|
| An unhandled exception of type 'System.Management.ManagementException'
| occurred in system.management.dll
|
| Additional information: This method is not implemented in any class
|
| thanks in adv.
| --
| LZ

Note that this only works on XP or W2K3 or higher.

using (ManagementObject dir= new
ManagementObject("Win32_Computersystem.name='" + Environment.MachineName +
"'"))
{
ManagementBaseObject inputArgs = dir.GetMethodParameters("Rename");
inputArgs["Name"] = "NewName";
ManagementBaseObject outParams = dir.InvokeMethod("Rename", inputArgs,
null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret == 0)
// OK
else
// Failed
}

Willy.

May 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error...
0
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error...
1
by: Dan Weatherman | last post by:
Hi all, Using WMI I am attempting to catch and exception when doing a managementscope.connect operation. From the looks of things, this method starts a new worker thread through Interop that then...
2
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.