From: AdamM on
Hi all,

I am writing a WMI script for screen brightness. I have to pass a value oif
uint8 and uint64. My script below fails with an invalid parameter error on
the last line. What is the proper syntax to pass the uint8 and uint64
values?

The API I am calling is this:

uint32 WmiSetBrightness(
uint8 Brightness,
uint64 Timeout
);
Here's the script (the last line is apparently the problem):

set services=getobject("winmgmts:root\wmi")
set mon=services.get("WmiMonitorBrightnessMethods")
mon.WmiSetBrightness 100,1

Any tips would be greatly appreciated!
Adam


From: mr_unreliable on
hi Adam,

This could get tricky.

I suggest attempting to use the vbs type-conversion routines,
for example, CByte(100) might give you an unsigned 8-bit
integer.

Unfortunately, there is no native vbs 64-bit integer, but you
might try playing around with the currency (or date) type.

The real trickiness comes with how far wmi goes with its
type-checking. That is, there ARE variants of subtype
unsigned integer, but not available to vbscripters. If
wmi is looking at the "variant type" of the variant typedef,
then you may be unable to use that feature from script
without some bit-twiddling.

Just in case you DO happen to be up for a bit of bit-twiddling,
here is a table of the valid variant types.

* VARENUM usage key,
*
* * [V] - may appear in a VARIANT
* * [T] - may appear in a TYPEDESC
* * [P] - may appear in an OLE property set
* * [S] - may appear in a Safe Array
*
*
* VT_EMPTY [V] [P] nothing
* VT_NULL [V] [P] SQL style Null
* VT_I2 [V][T][P][S] 2 byte signed int
* VT_I4 [V][T][P][S] 4 byte signed int
* VT_R4 [V][T][P][S] 4 byte real
* VT_R8 [V][T][P][S] 8 byte real
* VT_CY [V][T][P][S] currency
* VT_DATE [V][T][P][S] date
* VT_BSTR [V][T][P][S] OLE Automation string
* VT_DISPATCH [V][T][P][S] IDispatch *
* VT_ERROR [V][T][P][S] SCODE
* VT_BOOL [V][T][P][S] True=-1, False=0
* VT_VARIANT [V][T][P][S] VARIANT *
* VT_UNKNOWN [V][T] [S] IUnknown *
* VT_DECIMAL [V][T] [S] 16 byte fixed point
* VT_RECORD [V] [P][S] user defined type
* VT_I1 [V][T][P][s] signed char
* VT_UI1 [V][T][P][S] unsigned char
* VT_UI2 [V][T][P][S] unsigned short
* VT_UI4 [V][T][P][S] unsigned short
* VT_I8 [T][P] signed 64-bit int
* VT_UI8 [T][P] unsigned 64-bit int
* VT_INT [V][T][P][S] signed machine int
* VT_UINT [V][T] [S] unsigned machine int
* VT_VOID [T] C style void
* VT_HRESULT [T] Standard return type
* VT_PTR [T] pointer type
* VT_SAFEARRAY [T] (use VT_ARRAY in VARIANT)
* VT_CARRAY [T] C style array
* VT_USERDEFINED [T] user defined type
* VT_LPSTR [T][P] null terminated string
* VT_LPWSTR [T][P] wide null terminated string
* VT_FILETIME [P] FILETIME
* VT_BLOB [P] Length prefixed bytes
* VT_STREAM [P] Name of the stream follows
* VT_STORAGE [P] Name of the storage follows
* VT_STREAMED_OBJECT [P] Stream contains an object
* VT_STORED_OBJECT [P] Storage contains an object
* VT_BLOB_OBJECT [P] Blob contains an object
* VT_CF [P] Clipboard format
* VT_CLSID [P] A Class ID
* VT_VECTOR [P] simple counted array
* VT_ARRAY [V] SAFEARRAY*
* VT_BYREF [V] void* for local use
* VT_BSTR_BLOB Reserved for system use
*/





AdamM wrote:
> Hi all,
>
> I am writing a WMI script for screen brightness. I have to pass a value oif
> uint8 and uint64. My script below fails with an invalid parameter error on
> the last line. What is the proper syntax to pass the uint8 and uint64
> values?
>
> The API I am calling is this:
>
> uint32 WmiSetBrightness(
> uint8 Brightness,
> uint64 Timeout
> );
> Here's the script (the last line is apparently the problem):
>
> set services=getobject("winmgmts:root\wmi")
> set mon=services.get("WmiMonitorBrightnessMethods")
> mon.WmiSetBrightness 100,1
>
> Any tips would be greatly appreciated!
> Adam
>
>