HighTechTalks DotNet Forums  

Getting error executing the Win32Shutdown method C++

Dotnet Framework (WMI) microsoft.public.dotnet.framework.wmi


Discuss Getting error executing the Win32Shutdown method C++ in the Dotnet Framework (WMI) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
cpp_geek
 
Posts: n/a

Default Getting error executing the Win32Shutdown method C++ - 05-13-2008 , 03:32 AM






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.

Reply With Quote
  #2  
Old   
cpp_geek
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 05-13-2008 , 11:51 PM






Thanks anyway...
I've soved my problem.....

"cpp_geek" wrote:

Quote:
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.

Reply With Quote
  #3  
Old   
cpp_geek
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 05-13-2008 , 11:51 PM



Thanks anyway...
I've soved my problem.....

"cpp_geek" wrote:

Quote:
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.

Reply With Quote
  #4  
Old   
hhool
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 12:16 AM




How do it right?can you pls tell me? thanks
"cpp_geek" wrote:

Quote:
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.

Reply With Quote
  #5  
Old   
hhool
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 12:16 AM




How do it right?can you pls tell me? thanks
"cpp_geek" wrote:

Quote:
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.

Reply With Quote
  #6  
Old   
cpp_geek
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 01:27 AM



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:

Quote:
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.

Reply With Quote
  #7  
Old   
cpp_geek
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 01:27 AM



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:

Quote:
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.

Reply With Quote
  #8  
Old   
hhool
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 02:49 AM



I don't know how to do it ,can you give me the right sample.
My Email :hhool.student (AT) sina (DOT) com. Thanks

"cpp_geek" wrote:

Quote:
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.

Reply With Quote
  #9  
Old   
hhool
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 02:49 AM



I don't know how to do it ,can you give me the right sample.
My Email :hhool.student (AT) sina (DOT) com. Thanks

"cpp_geek" wrote:

Quote:
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.

Reply With Quote
  #10  
Old   
hhool
 
Posts: n/a

Default RE: Getting error executing the Win32Shutdown method C++ - 07-08-2008 , 02:52 AM



I don't know how to do it ,can you give me the right sample.
My Email :hhool.student (AT) sina (DOT) com. The EMail Adr is also my MSN account,Thanks.

"cpp_geek" wrote:

Quote:
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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.