![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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. |
#3
| |||
| |||
|
|
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. |
#4
| |||
| |||
|
|
Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
#5
| |||
| |||
|
|
Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
#6
| |||
| |||
|
|
How do it right?can you pls tell me? thanks "cpp_geek" wrote: Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
#7
| |||
| |||
|
|
How do it right?can you pls tell me? thanks "cpp_geek" wrote: Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
#8
| |||
| |||
|
|
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" wrote: How do it right?can you pls tell me? thanks "cpp_geek" wrote: Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
#9
| |||
| |||
|
|
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" wrote: How do it right?can you pls tell me? thanks "cpp_geek" wrote: Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
#10
| |||
| |||
|
|
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" wrote: How do it right?can you pls tell me? thanks "cpp_geek" wrote: Thanks anyway... I've soved my problem..... "cpp_geek" wrote: 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. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |