Re: Setting registry data
- From: "Arun Mohan" <arunthe1@xxxxxxxxx>
- Date: Wed, 6 Sep 2006 01:38:14 +0530
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.UPDATE_FLAG
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
only and so it will always fail and will never work.rights.
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
example
"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
"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
theC++
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
http://groups.google.de/group/microsoft.public.win32.programmer.wmi/browse_tIWbemServicesPut() method of IWbemClassObject or PutInstance() method of
?
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
done.a6b003e730
hope
Again, this example shows how to read values from the registry but I
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
message
Regards,
Sandhya
"Jonathan Liu [MSFT]" <jonliu@xxxxxxxxxxxxxxxxxxxx> wrote in
"root\cimv2")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,
noobjService.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
atrights.
Use of included script samples are subject to the terms specified
parameterhttp://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
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/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
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: Manbinder Pal Singh [MSFT]
- Re: Setting registry data
- References:
- Re: Setting registry data
- From: Manbinder Pal Singh [MSFT]
- Re: Setting registry data
- Prev by Date: looping over wbemObjectSet
- Next by Date: Re: Perf Counters - Processor Queue Length
- Previous by thread: Re: Setting registry data
- Next by thread: Re: Setting registry data
- Index(es):
Relevant Pages
|
Loading