Setting computer name with WMI

Joined
Jun 29, 2007
Messages
1
Reaction score
0
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
smiley_confused.gif
. Need help. Thanks



one-trick-pony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top