Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

91 lines
2.1 KiB

<!--
******************************************************************
'
' arrayvalue.wsf
'
' Purpose: test SWbemPropertyEx::ArrayValue
'
' Parameters: none
'
' Returns: 0 - success
' 1 - failure
'
'*****************************************************************
-->
<job id="WMI ArrayValue Test">
<reference object="WbemScripting.SWbemLocator" version="1.2"/>
<script language="VBScript">
on error resume next
set scriptHelper = CreateObject("WMIScriptHelper.WSC")
scriptHelper.logFile = "c:\temp\arrayvalue.txt"
scriptHelper.loggingLevel = 3
scriptHelper.testName = "WMI ArrayValue"
scriptHelper.testStart
dim ns
dim newClass
' Connect to the namespace
set ns = GetObject("winmgmts:root\default")
if err <> 0 then
scriptHelper.writeErrorToLog err, "Failed to connect to root\default"
else
scriptHelper.writeToLog "Successful connection to root\default", 2
end if
'Make a new class
set newClass = ns.Get
if err <> 0 then
scriptHelper.writeErrorToLog err, "Failed to get empty class"
else
scriptHelper.writeToLog "Successful retrieval of empty class", 2
end if
newClass.Path_.Class = "ARRAYVALUE000TEST"
if err <> 0 then
scriptHelper.writeErrorToLog err, "Failed to set class name"
else
scriptHelper.writeToLog "Successful set of class name", 2
end if
' Add a non-array property (uint32)
set p0 = newClass.Properties_.Add ("p0", wbemCimtypeUint32)
p0.Value = 251
' Add an array property
set p1 = newClass.Properties_.Add ("p1", wbemCimtypeUint32, true)
p1.Value = Array (1, 2, 3)
' Try getting a non array value as an array
v = p0.ArrayValue
scriptHelper.DisplayValue newClass, "p0"
scriptHelper.VerifyValue v, Array(251)
' Try getting an array value as an array
v = p1.ArrayValue
scriptHelper.DisplayValue newClass, "p1"
scriptHelper.VerifyValue v, Array (1, 2, 3)
' Try a null value
p0.Value = null
scriptHelper.DisplayValue newClass, "p0"
scriptHelper.VerifyValue p0.ArrayValue, null
scriptHelper.testComplete
if scriptHelper.statusOK then
WScript.Echo "PASS"
WScript.Quit 0
else
WScript.Echo "FAIL"
WScript.Quit 1
end if
</script>
</job>