Re: Setting registry data



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 SpawnInstance

and then you put various property values in that instance using Put
method.
These is uncommited instance. In order to finaly put it you should use
PutInstance method of IWemservice.

Thanks,
Manbinder Pal Singh

This posting is provided "AS IS" with no warranties, and confers no
rights.


"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
C++
code.
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
IWbemServices
?
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:

http://groups.google.de/group/microsoft.public.win32.programmer.wmi/browse_t
hread/thread/5f6976ad37f0b51c/6c6b3ba6b003e730?lnk=st&q=&rnum=1&hl=de#6c6b3b
a6b003e730

Again, this example shows how to read values from the registry but I
hope
this 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
of
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


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
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

















.



Relevant Pages

  • Re: Cant rip to MP3 with new but with old Dell?
    ... finally got around to making the change to my registry from l3codeca.acm to ... See http://zachd.com/pss/pss.html for some helpful WMP info. ... This posting is provided "AS IS" with no warranties, and confers no rights. ...
    (microsoft.public.windowsmedia)
  • Re: ISA Block Destination Set, wants login info
    ... the code fixes are there, but the registry settings are not applied. ... was and always will be the case for ISA hotfixes because not everyone experiences the same issues. ... This posting is provided "AS IS" with no warranties, and confers no rights. ...
    (microsoft.public.isaserver)
  • Re: How to get the memory frequency in windows OS?
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... >I know that the CPU frequency is saved in the registry. ... Maybe it is not in the registry. ...
    (microsoft.public.development.device.drivers)
  • Re: WMP repeated need for critical update KB828026
    ... >> Gee, Zach, thanks for the homework assignment! ... >> crawling through the registry I'll let you know. ... >> confers no rights. ...
    (microsoft.public.windowsmedia.player)
  • Re: Setting registry data
    ... I have tried with ExecQuery, followed by modification, put instance. ... Can you please provide me a sample code or the link for the same? ... IWbemClassObject* pClassInstance = NULL; ... this example shows how to read values from the registry but I ...
    (microsoft.public.win32.programmer.wmi)