- 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
. Need help. Thanks
one-trick-pony
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

one-trick-pony