// set up to call the SystemRestore::Restore method
BSTR MethodName = SysAllocString(L"Restore");
BSTR ClassName = SysAllocString(L"SystemRestore");
IWbemClassObject* pClass = NULL;
hres = service->GetObject(ClassName, 0, NULL, &pClass, NULL);
IWbemClassObject* pInParamsDefinition = NULL;
hres = pClass->GetMethod(MethodName, 0, &pInParamsDefinition, NULL);
IWbemClassObject* pClassInstance = NULL;
hres = pInParamsDefinition->SpawnInstance(0, &pClassInstance);
// Create the values for the in parameters
VARIANT varCommand;
varCommand.vt = VT_I4;
varCommand.iVal = nRestoreSequenceNumber_;
// Store the value for the in parameters
hres = pClassInstance->Put(L"SequenceNumber", 0, &varCommand, 0);
// Execute Method
IWbemClassObject* pOutParams = NULL;
hres = service->ExecMethod(ClassName, MethodName, 0, NULL, pClassInstance,
&pOutParams, NULL);
Any ideas what could be wrong?
Thanks
It can help you too much
Seyfullah İZMİRLİ
Software Specialist
"rmckee" <rmc...@discussions.microsoft.com>, haber iletisinde şunları
yazdı:15B38C7E-5928-4EE1...@microsoft.com...
I need code for C++.
Is there a similiar code generator for C++?
"Seyfullah ÝZMÝRLÝ" wrote:
> use this file
> WMICodeCreator.exe
> search with google
>
> It can help you too much
>
> Seyfullah ÝZMÝRLÝ
> Software Specialist
>
> "rmckee" <rmc...@discussions.microsoft.com>, haber iletisinde þunlarý
> yazdý:15B38C7E-5928-4EE1...@microsoft.com...
What happens if you run this instead? (fix word wrap first)
Set RPSet = GetObject("winmgmts:root/default").InstancesOf ("SystemRestore")
for each RP in RPSet
wscript.Echo "Dir: RP" & RP.SequenceNumber & ", Name: " &
RP.Description & ", Type: ", RP.RestorePointType & ", Time: " &
RP.CreationTime
next
If that works, are you able to use the other methods such as "Enable",
"Disable" and "GetLastREstoreStatus"?
--
Gerry Hickman (London UK)
IWbemLocator *pLocator = NULL;
IWbemServices *pNamespace = 0;
IWbemClassObject * pClass = NULL;
IWbemClassObject * pOutInst = NULL;
IWbemClassObject * pInClass = NULL;
IWbemClassObject * pInInst = NULL;
BSTR path = SysAllocString(L"root\\default");
BSTR ClassPath = SysAllocString(L"SystemRestore");
BSTR MethodName = SysAllocString(L"Restore");
BSTR ArgName = SysAllocString(L"SequenceNumber");
BSTR Text;
// Initialize COM and connect to WMI.
HRESULT hr = CoInitialize(0);
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLocator);
hr = pLocator->ConnectServer(path, NULL, NULL, NULL, 0, NULL,
NULL, &pNamespace);
// Get the class object for the method definition.
hr = pNamespace->GetObject(ClassPath, 0, NULL, &pClass, NULL);
// Get the input-argument class object and create an instance.
hr = pClass->GetMethod(MethodName, 0, &pInClass, NULL);
hr = pInClass->SpawnInstance(0, &pInInst);
// Set the property.
VARIANT var;
var.vt = VT_I4;
var.iVal = nRestoreSequenceNumber_;
hr = pInInst->Put(ArgName, 0, &var, 0);
VariantClear(&var);
// Call the method.
hr = pNamespace->ExecMethod(ClassPath, MethodName, 0, NULL,
pInInst, &pOutInst, NULL);
// Display the results. Note that the return value is in the
// property "ReturnValue" and the returned string is in the
// property "sOutArg".
hr = pOutInst->GetObjectText(0, &Text);
printf("\nThe object text is:\n%S", Text);
// Free up resources.
SysFreeString(path);
SysFreeString(ClassPath);
SysFreeString(MethodName);
SysFreeString(ArgName);
SysFreeString(Text);
pClass->Release();
pInInst->Release();
pInClass->Release();
pOutInst->Release();
pLocator->Release();
pNamespace->Release();
CoUninitialize();
printf("Terminating normally\n");