Re: Setting registry data



Hi Manbinder,
I have tried with ExecQuery, followed by modification, put instance. It is
not working for me.

Can you please provide me a sample code or the link for the same?

I tried in google, but i was able to get codes in script format, not in
VC++.

Thanks,
Arun M



"Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx> wrote in message
news:OTKlZHZzGHA.1268@xxxxxxxxxxxxxxxxxxxxxxx
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: Setting registry data
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... IWbemClassObject* pClassInstance = NULL; ... this example shows how to read values from the registry but I ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Setting registry data
    ... IWbemClassObject* pClassInstance = NULL; ... Which is the equivalent C++ call to Put_ method in VBScript? ... this example shows how to read values from the registry but I ... I am using WMI to read the data through WQL. ...
    (microsoft.public.win32.programmer.wmi)
  • Reading and Writing the Registry
    ... I've seen a few different methods for reading and writing the registry. ... Under this root are the individual keys each of which has a single value, ... I need to be able to step through all of the names under AddressBook, ... sparse and the sample code is useless. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Access AVI in resource dll with AVI API
    ... > is it possible to do this without modify any registry ... The sample is in the DirectShow SDK, ... about COM but what the sample code shows you. ... // a dot angeli at psynet dot net ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Determine Available Browsers
    ... Sample code please. ... I don't know much about accessing the registry by keys etc. ... will get you the command line necessary to start up the default browser. ...
    (microsoft.public.vb.general.discussion)

Loading