|
|
|||||||
hi, i use the folowing script for getting the disk size + free size. Code: $computer = "." $objWMIService = GetObject( "winmgmts://" + $computer + "/root/CIMV2" ) $colDisks = $objWMIService.ExecQuery("Select * FROM Win32_LogicalDisk") For Each $objDisk in $colDisks Select Case $objDisk.DriveType = "2" $Devtype = "floppy drive." Case $objDisk.DriveType = "3" $DevType = "hard drive." ? " " ? " Drive: " + $objDisk.Name ? " Device type:................" + $DevType ? " File System:................" + $objDisk.FileSystem $dfs=CInt ($objDisk.FreeSpace) $dds=Cint ($objDisk.Size) $sss= $dds - $dfs ? " Free Space:................." + $objDisk.FreeSpace + " / " + $objDisk.Size ? "amir : " + $sss + " - " + $dfs + " - " + $dds ? " " Case $objDisk.DriveType = "4" $DevType = "mapped network drive." Case $objDisk.DriveType = "5" $DevType = "CD or DVD drive." ? " " ? " Drive: " + $objDisk.Name ? " Device type:................" + $DevType ? " " Case 1 $DevType = "Unknown" EndSelect the result i get: Drive: C: Device type:................hard drive. File System:................NTFS Free Space:.................229501284352 / 319697539072 amir : 0 - 2147483647 - 2147483647 why i get the number 2147483647 instead of: 229501284352 ?? how can i get the real numbers at the free space?? and do some math on them?? thanks... |
||||||||
|
|
|||||||
Hi Matzas, Well, I would guess since you are rounding the numbers to an integer when setting $dfs and $dds. What happens if you remove the cint from each line? Does $sss become 90196254720? |
||||||||
|
|
|||||||
thanks for your answer.... when i remove the cint from both of the lines i get an error in the kix script... when i remark the line "$sss= $dds - $dfs" i see the real value... the result are: Drive: C: Device type:................hard drive. File System:................NTFS Free Space:.................213 GB Free Space:.................229491920896 / 319697539072 amir : - 229491920896 - 319697539072 but i can't do any math activities... how do i asure that the values in $dds and in $dfs are numbers and not strings?.. (is that the problem??) please help. thanks., |
||||||||
|
|
|||||||
No, the problem is that you are exceeding the maximum value that KiXtart can handle. The numbers are too big. One simple solution is just to drop the last 3 digits from the string to scale the number as kilobytes (give or take) and then convert to numeric. This is often close enough. This problem comes up with disk drive sizes quite regularly, if you search the forums you will find other suggestions for workarounds. |