Re: Setting registry data
- From: "Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx>
- Date: Fri, 1 Sep 2006 12:12:49 +0530
What you are doing is wrong.
You are creating a class object by giving class name. This will try to
create a new object instance for win32_registry and as you pass UPDATE_FLAG
only and so it will always fail and will never work.
What you should do is do either
1. Execquery on win32_registry or
2. Pass the exact path of win32_registry object ( you can enumurate
instances in wbemtest of this class and see the path of that object )
and then follow with the modification,put and putinstance.
Thanks,
Manbinder Pal Singh
This posting is provided "AS IS" with no warranties, and confers no rights.
"Arun Mohan" <arunthe1@xxxxxxxxx> wrote in message
news:eHP3BpSzGHA.4232@xxxxxxxxxxxxxxxxxxxxxxx
Hi Manbinder,
I have used spawninstanc, put instance, Still i am not able to see the
modification happening...
I have attached the code for reference. Please let me know where i am
going
wrong.
void setProposedSize(long theProposedSize){
VARIANT vtProp;
VariantInit(&vtProp);
//This function will connect to server
if( Registry::isInitialised == 0 )
Registry::initialize();
//This getServiceObj will return IWbemServices object
IWbemServices* pSvc = getSeviceObj();
BSTR ClassName = SysAllocString(L"Win32_Registry");
IWbemClassObject* pClass = NULL;
HRESULT hres = pSvc->GetObject(ClassName, 0, NULL, &pClass, NULL);
IWbemClassObject* pClassInstance = NULL;
hres = pClass->SpawnInstance(0, &pClassInstance);
V_VT(&vtProp) = TYPE_UINT;
vtProp.uintVal = (unsigned int)theProposedSize;
cout<<"Setting proposed size :" << theProposedSize<<endl ;
HRESULT hr = pClassInstance->Put(L"ProposedSize", 0, &vtProp, 0);
switch(hr)
{
case WBEM_S_NO_ERROR:
cout<<"suceeded";
break;
case WBEM_E_FAILED:
cout<<"WBEM_E_FAILED";
break;
case WBEM_E_INVALID_PARAMETER:
cout<<"WBEM_E_INVALID_PARAMETER";
break;
case WBEM_E_INVALID_PROPERTY_TYPE:
cout<<"WBEM_E_INVALID_PROPERTY_TYPE";
break;
case WBEM_E_OUT_OF_MEMORY:
cout<<"WBEM_E_OUT_OF_MEMORY";
break;
case WBEM_E_TYPE_MISMATCH:
cout<<"WBEM_E_TYPE_MISMATCH";
break;
}
IWbemCallResult* pResult = 0;
IWbemContext* pCtx = 0;
IWbemObjectSink *pSink = 0;
hr =
pSvc->PutInstance(pClassInstance,WBEM_FLAG_UPDATE_ONLY,NULL,&pResult);
cout<< "pResult:" << pResult << endl;
if (FAILED(hr))
{
cout<<endl<<"failed sadly"<<endl;
}
switch(hr)
{
case WBEM_E_ACCESS_DENIED:
cout<<"WBEM_E_ACCESS_DENIED";
break;
case WBEM_E_FAILED:
cout<<"WBEM_E_FAILED";
break;
case WBEM_E_INVALID_PARAMETER:
cout<<"WBEM_E_INVALID_PARAMETER";
break;
case WBEM_E_INVALID_CLASS:
cout<<"WBEM_E_INVALID_CLASS";
break;
case WBEM_E_INVALID_OPERATION:
cout<<"WBEM_E_INVALID_OPERATION";
break;
case WBEM_E_CLASS_HAS_CHILDREN:
cout<<"WBEM_E_CLASS_HAS_CHILDREN";
break;
case WBEM_E_INCOMPLETE_CLASS:
cout<<"WBEM_E_INCOMPLETE_CLASS";
break;
case WBEM_E_OUT_OF_MEMORY:
cout<<"WBEM_E_OUT_OF_MEMORY";
break;
case WBEM_E_SHUTTING_DOWN:
cout<<"WBEM_E_SHUTTING_DOWN";
break;
case WBEM_E_TRANSPORT_FAILURE:
cout<<"WBEM_E_TRANSPORT_FAILURE";
break;
case WBEM_S_NO_ERROR:
cout<<"WBEM_S_NO_ERROR";
break;
case WBEM_E_ALREADY_EXISTS:
cout<<"WBEM_E_ALREADY_EXISTS";
break;
case WBEM_E_NOT_FOUND:
cout<<"WBEM_E_NOT_FOUND";
break;
}
SysFreeString(ClassName);
pClass->Release();
VariantClear(&vtProp);
}
Thanks,
Arun M
(on behalf of Sandhya)
"Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx> wrote in message
news:OTAd5gAzGHA.5072@xxxxxxxxxxxxxxxxxxxxxxx
You should first make a new object using IWbemClassObject SpawnInstancemethod.
and then you put various property values in that instance using Put
These is uncommited instance. In order to finaly put it you should userights.
PutInstance method of IWemservice.
Thanks,
Manbinder Pal Singh
This posting is provided "AS IS" with no warranties, and confers no
C++
"Sandhya M" <mnsandhya@xxxxxxxxx> wrote in message
news:O4VoK84yGHA.4648@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I tried using the VBScript and it is working fine. I tried the example
IWbemServicescode.
The value is not getting set with C++ code. I have a query here -
Which is the equivalent C++ call to Put_ method in VBScript ? Is it the
Put() method of IWbemClassObject or PutInstance() method of
http://groups.google.de/group/microsoft.public.win32.programmer.wmi/browse_t?
Regards,
Sandhya
"August Quint" <acquint@xxxxxxxxxxx> wrote in message
news:1155041216.459761@xxxxxxxxxxxxxxxxxxxx
Sandhya,
I knew there was another example and luckily I found it, here:
hread/thread/5f6976ad37f0b51c/6c6b3ba6b003e730?lnk=st&q=&rnum=1&hl=de#6c6b3b
a6b003e730
hope
Again, this example shows how to read values from the registry but I
ofthis shows the way to go.
August
"Sandhya M" <mnsandhya@xxxxxxxxx> schrieb im Newsbeitrag
news:%23P2LzMquGHA.2224@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am using C++ code. Can you please let me know how this can be done.
Regards,
Sandhya
"Jonathan Liu [MSFT]" <jonliu@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:uev$0IluGHA.4384@xxxxxxxxxxxxxxxxxxxxxxx
You can do something like this: (modify the ProposedSize to what
you
require)
strComputer = "."
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer(strComputer, "root\cimv2")
objService.Security_.ImpersonationLevel = 3
Set Registry = _
objService.ExecQuery("SELECT * FROM Win32_Registry")
For each Reg in Registry
WScript.Echo "Old Size: " & Reg.ProposedSize
Reg.ProposedSize = 77 '<--Change this...
Reg.Put_
WScript.Echo "New Size: " & Reg.ProposedSize
Next
--
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Sandhya M" <mnsandhya@xxxxxxxxx> wrote in message
news:OGCOq0euGHA.2224@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
Thanks for the reply. What I want to set is proposed size parameter
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_registry.
Please let me know how I can go about doing this.
Regards,
Sandhya
<joseomjr@xxxxxxxxx> wrote in message
news:1154911829.124625.47840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Look at the stdregprov class
stdregprov.asp
Sandhya M wrote:
Hi,
I am using WMI to read the data through WQL. I want to set the
registry
data.
Can I use WMI to do the same ?
Thanks,
Sandhya
.
- Follow-Ups:
- Re: Setting registry data
- From: Arun Mohan
- Re: Setting registry data
- Prev by Date: Re: Setting ComputerSystem class Parameters
- Next by Date: Re: Fire WMI Events
- Previous by thread: Re: Setting ComputerSystem class Parameters
- Next by thread: Re: Setting registry data
- Index(es):
Relevant Pages
|