Page 1 of 1 1
Topic Options
#92440 - 2003-07-15 07:33 PM number value from WMI
Voytech Offline
Lurker

Registered: 2003-05-08
Posts: 3
Loc: Poland
from WMIquery() i get a string value. How to convert it into a decimal value. I don't mean val(). I need the value i can see. Is it possible? [Frown]
Top
#92441 - 2003-07-15 07:40 PM Re: number value from WMI
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
more detail please..
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#92442 - 2003-07-15 07:45 PM Re: number value from WMI
Voytech Offline
Lurker

Registered: 2003-05-08
Posts: 3
Loc: Poland
This is a part of my script. I'm trying to retrieve disk space from my servers:

$myarray = 1, 2
For Each $element In $myarray


$Info = wmiquery ("Name","Win32_LogicalDisk", "cwtwaw05") [$element]

$element = $element - 1


$Total = wmiquery ("Size","Win32_LogicalDisk", "cwtwaw05") [$element]

$Free = wmiquery ("FreeSpace","Win32_LogicalDisk", "cwtwaw05") [$element]



$diskinformation = "CWTWAW05 :" + $Info + " "+$Total+" "+ $Free + @crlf
$servinformation = $servinformation + $diskinformation

Next

I'm using the following function:

Function WMIQuery($sWhat, $sFrom, Optional $sComputer, Optional $sWhere, Optional $x)

Dim $sQuery, $objEnum, $sValue, $sItem, $lUbound
Dim $aTMP[0]
$sQuery = "Select " + $sWhat + " From "+ $sFrom
If NOT $sComputer $sComputer=@WKSTA EndIf
If $sWhere AND $x $sQuery = $sQuery + " Where " + $sWhere + " = '"+$x+"'" EndIf
$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//"+$sComputer) If

@ERROR Exit Val("&"+Right(DecToHex(@ERROR),4)) Return EndIf
$objEnum = $SystemSet.ExecQuery($sQuery)
If @ERROR Exit Val("&"+Right(DecToHex(@ERROR),4)) Return
EndIf
For Each $objInstance In $objEnum
If $objInstance
$=Execute("$$sValue = $$objInstance.$sWhat")
Select
Case VarType($sValue) & 8192
For Each $sItem In $sValue
$lUbound = Ubound($aTMP)
If $aTMP[$lUbound] >' '

$lUbound = $lUbound +1
ReDim Preserve $aTMP[$lUbound]
EndIf
$aTMP[$lUbound] = Trim($sItem)
Next
Case 1
$lUbound = Ubound($aTMP)
If $aTMP[$lUbound] >' ' $lUbound = $lUbound +1
ReDim Preserve $aTMP[$lUbound]
EndIf $aTMP[$lUbound] = Trim($sValue)
EndSelect EndIf
Next
$WMIQuery = $aTMP
Exit Val("&"+Right(DecToHex(@ERROR),4))

EndFunction

Top
#92443 - 2003-07-15 07:51 PM Re: number value from WMI
Voytech Offline
Lurker

Registered: 2003-05-08
Posts: 3
Loc: Poland
But I cannot, for example, divide the size of free space by the size of the logical and multiply by 100 to get the percentage.
Top
#92444 - 2003-07-15 08:06 PM Re: number value from WMI
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please take a look at the KiXart Manual, it explains the differences between VAL, CDBL, and so on.

Secondly, take a look at the UDF Forum under DiskSpace() - returns the available disk space on a drive
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1363 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.131 seconds in which 0.109 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org