Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting error executing the Win32Shutdown method C++

103 views
Skip to first unread message

cpp_geek

unread,
May 13, 2008, 4:32:00 AM5/13/08
to
Hi,
Can any one tell me what did i do wrong in the following code: I'm getting
WBEM_E_INVALID_METHOD_PARAMETERS (0x8004102F) error code from ExecMethod

Code:
//pCimv2 is succesfully connected to : \\\\\.\\root\\cimv2
BSTR clsname = SysAllocString(L"Win32_OperatingSystem");
BSTR MethodName = SysAllocString(L"Win32Shutdown");
IWbemClassObject* pClsProc = NULL;
IWbemClassObject* pInParams = NULL;
IWbemClassObject* pOutMethod = NULL;
IWbemClassObject* pClsProcInst = NULL;

g_core_hr = pCimv2->GetObjectW(clsname, 0, NULL, &pClsProc, NULL);
if( SUCCEEDED(g_core_hr) ) {
g_core_hr = pClsProc->GetMethod(MethodName, 0, &pInParams,NULL);
if( SUCCEEDED(g_core_hr) ) {
g_core_hr = pInParams->SpawnInstance(0, &pClsProcInst);
if( SUCCEEDED(g_core_hr) ) {
VARIANT pcVal;
VARIANT rsVal;
VariantInit(&pcVal);
pcVal.vt = VT_I4;
pcVal.lVal = 1;
VariantInit(&rsVal);
rsVal.vt = VT_I4;
rsVal.lVal = 0;
g_core_hr = pClsProcInst->Put(L"Flags", 0,&pcVal, 0 );
g_core_hr = pClsProcInst->Put(L"Reserved", 0,&rsVal, 0);
if( SUCCEEDED(g_core_hr) ) {
g_core_hr = pCimv2->ExecMethod(clsname, MethodName, 0, NULL,
pClsProcInst, &pOutMethod, NULL);
if(FAILED(g_core_hr)) {
// getting the error
}
}
VariantClear(&pcVal);
VariantClear(&rsVal);
}
}
}

thanks.

cpp_geek

unread,
May 14, 2008, 12:51:00 AM5/14/08
to
Thanks anyway...
I've soved my problem.....

hhool

unread,
Jul 8, 2008, 1:16:00 AM7/8/08
to

How do it right?can you pls tell me? thanks

cpp_geek

unread,
Jul 8, 2008, 2:27:00 AM7/8/08
to
You need to pass the class instance name in the first param 'clsname'. So
instead of "Win32_OperatingSystem" pass "Win32_OperatingSystem=@" for local
system. If you are trying to shutdown a remote machine then it is dynamic..
which could be queried and retrived. this is the value of __RELPATH

pCimv2->ExecMethod(clsname, MethodName, 0, NULL, pClsProcInst, &pOutMethod,
NULL);

If you face anymore trouble then let me know.

hhool

unread,
Jul 8, 2008, 3:49:01 AM7/8/08
to
I don't know how to do it ,can you give me the right sample.
My Email :hhool....@sina.com. Thanks

hhool

unread,
Jul 8, 2008, 3:52:00 AM7/8/08
to
I don't know how to do it ,can you give me the right sample.
My Email :hhool....@sina.com. The EMail Adr is also my MSN account,Thanks.

don_franc

unread,
Sep 15, 2010, 8:17:27 AM9/15/10
to
HI cpp_geek,
I have the same problem just like you. Can you tell me how did you solved it?
Thanks!

From http://www.developmentnow.com/g/33_2008_5_0_0_1060473/Getting-error-executing-the-Win32Shutdown-method-C.htm

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

0 new messages