Re: Setting ComputerSystem class Parameters
- From: "Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx>
- Date: Fri, 1 Sep 2006 12:12:43 +0530
I replied on one another thread. Copying the same
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.
"Sandhya M" <mnsandhya@xxxxxxxxx> wrote in message
news:uHSTgpzyGHA.4480@xxxxxxxxxxxxxxxxxxxxxxx
Hi Manbinder
Following is the sampel code: We are trying to set proposed size
(Win32_Registry)
and volume label (Win32_LogicalDisk)
OS used is WinXP sp2.
---------------------------------------------------------------------------------------
For Win32_Registry
void setProposedSize(long theProposedSize){
VARIANT vtProp;
VariantInit(&vtProp);
if( Registry::isInitialised == 0 )
Registry::initialize();
V_VT(&vtProp) = TYPE_UINT;
vtProp.ulVal = (unsigned int)theProposedSize;
HRESULT hr = Registry::obj->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;
}
VariantClear(&vtProp);
}
For Win32_LogicalDisk
void setVolumeName() {
VARIANT vtProp;
VariantInit(&vtProp);
if( LogicalDisk::isInitialised == 0 )
LogicalDisk::initialize();
V_VT(&vtProp) = VT_BSTR;
V_BSTR(&v) = SysAllocString(L"myVolume");
HRESULT hr = LogicalDisk::obj->Put(L"VolumeName", 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;
}
VariantClear(&vtProp);
}
----------------------------------------------------------------------------------
"Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx> wrote in message
news:%23nXjEwmyGHA.3464@xxxxxxxxxxxxxxxxxxxxxxx
I will try to see.Can you please tell me which all properties gets
reverted? (What old values and new values you give )
+
Give your OS+SKU details.
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:u23KyoDyGHA.4524@xxxxxxxxxxxxxxxxxxxxxxx
Hi Manbinder,
The issue is that the change is reflected immediately and upon reboot it
goes back to the
old value.
Regards,
Sandhya
"Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx> wrote in message
news:OpDbJoCyGHA.2036@xxxxxxxxxxxxxxxxxxxxxxx
Some of the properties might require reboot.
see if it works for you. Else can you tell which property you changed
and what you see along with OS details.
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:uyEnxe2xGHA.4336@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have implemented the same in VC++. I have used
IWbemClassObject.put( ).
This particular call modifies the value in Local Instance only. On the
next execution of the program or After rebooting the machine, i am not
able to get the modified value.
How to propagate this modification to the computer system, so that
when i run the program next time or after reboot i can see the
changes.
Can i do it thru WMI?
Regards,
Sandhya
"Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx> wrote in message
news:eBfMgG5uGHA.4752@xxxxxxxxxxxxxxxxxxxxxxx
If the properties are read/write then you can set properties like
below
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colSWbemObjectSet =
objSWbemServices.InstancesOf("Win32_ComputerSystem")
For Each objSWbemObject In colSWbemObjectSet
WScript.Echo objSWbemObject.AutomaticResetBootOption
objSWbemObject.AutomaticResetBootOption= "TRUE"
On Error Resume Next
objSWbemObject.Put_
If Err.Number <> 0 Then
WScript.Echo Err.Number & ": " & Err.Description
End If
Next
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:%23iTLWv3uGHA.1296@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I see that these parameters have read/write access. Can you please
let me know why
WMI can not be used to write these parameters.
Regards,
Sandhya
"Manbinder Pal Singh [MSFT]" <manbins@xxxxxxxxxxxxx> wrote in
message news:OWnB2qiuGHA.1284@xxxxxxxxxxxxxxxxxxxxxxx
If youare looking to do this through WMI then you cannot do this.
You need to change it by using win32 APIS and then if you check
win32_computersystem it should give you the changed results.
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:ONT5%23pguGHA.4460@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I need to set the following parameters of Win32_ComputerSystem
class.
AutomaticResetBootOption
CurrentTimeZone
SystemStartupDelay
SystemStartupOptions
SystemStartupSetting
EnableDaylightSavingsTime
Workgroup
Can you please let me know how do I go about doing this.
Regards,
Sandhya
.
- Prev by Date: Re: Getting class names with the API?
- Next by Date: Re: Setting registry data
- Previous by thread: Re: How to get Primary DNS suffix?
- Next by thread: Re: Setting registry data
- Index(es):
Relevant Pages
|