PC Review Forums Newsgroups Windows XP Windows XP WMI Setting computer name with WMI

Reply

Setting computer name with WMI

 
Thread Tools Rate Thread
Old 29-06-2007, 06:21 PM   #1
one-trick-pony
Junior Member
 
Join Date: Jun 2007
Posts: 1
Trader Rating: (0)
Default Setting computer name with WMI


Greetings,

I have been trying to figure out how to set computer name with WMI in C++. Below is part of the code to help demonstrate what I am doing.


VARIANT varCommand;
varCommand.vt = VT_BSTR;
//New computer name
varCommand.bstrVal = L"NewHostName01";
//Property that I wish to change is Name
hr = pInInst->Put(L"Name", 0, &varCommand, 0);
IWbemClassObject * pOutInst = NULL;
// Execute Rename method from class Win32_ComputerSystem
hr = pNamespace->ExecMethod(L"Win32_ComputerSystem", L"Rename",0,NULL, pInInst, &pOutInst, NULL);

ExecMethod fails with following error message: WBEM_E_INVALID_METHOD_PARAMETERS. I believe "Rename" is a non-static method thus ExecMethod reports preceeding error message. I don't know how to properly code for the non-static case. Need help. Thanks



one-trick-pony
one-trick-pony is offline   Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off