Re: Setting registry data



I will try to see sometime later. But it should be easy to map a script to a
VC++ code.

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:ev5f7iS0GHA.4920@xxxxxxxxxxxxxxxxxxxxxxx
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: OldNormal.dot Only Worked Once
    ... it is the same Steve that you helped late last week. ... The problem as previously stated in second posting is it only works once ... Let's start with the Registry first. ... I also tried 'start','run','winword /a' and that no longer opens ...
    (microsoft.public.office.misc)
  • Re: Std Users, Update Files?
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... I use a VB script which simply points to a BAT file. ...
    (microsoft.public.windows.server.general)
  • Re: PolAdtEv
    ... I did try posting a question about this on ... entire array instead of just the first 254 characters? ... >This is more a WMI question and not SMS related. ... tried tojsut get the data from the registry into ...
    (microsoft.public.sms.inventory)
  • Re: Javascript in an HTML table
    ... [previous posting superseded in the face of new evidence] ... This just displays my graph by itself. ... The <script ...> tag that was in the original code is missing here. ... Prototype.js was written by people who don't know javascript for people who ...
    (comp.lang.javascript)
  • Re: Unwanted start screen
    ... Since I have svc pk 2 on my machine I am afraid to use the xp cd as ... state by using upper case lettering in your posting. ... First - what do you mean by, "Since I cleaned out my registry"? ... important - since you are making the connection to cleaning your ...
    (microsoft.public.windowsxp.general)