Jump to content

Recommended Posts

Posted

Is there a way to get disk size if the drive is not formatted? Only thing i know is the disk id number from the winodws disk management?

Thanks

you can use the wmi i guess

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For $objItem In $colItems
    $size = $objItem.Size
Next

MsgBox(0, "DriveSize", $size)

[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

  • Moderators
Posted

Made the script a little more user friendly.

$strComputer = InputBox("Computer Name", "Please enter the computer name" & @Lf & "you wish to get drive size from.")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For $objItem In $colItems
    $size = $objItem.Size
Next
$size = $size / 1073741824
$capacity = StringFormat("%.2f", $size)
MsgBox(0, "DriveSize", $capacity & "GB")
  • Moderators
Posted

Could someone help me turn $colDisks into an array?

$strComputer = InputBox("Computer Name", "Please enter the computer name" & @Lf & "you wish to get drive size from.")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colDisks = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")

For $objDisk In $colDisks
    $device = StringTrimLeft($objDisk.DeviceID, 4)  
    $size = $objDisk.Size / 1073741824
    $capacity = StringFormat("%.2f", $size) 
    MsgBox(0, "", "DeviceID: " & $device & @LF & "Disk Size: " & $capacity & "GB")
    If @error <> 0 Then ExitLoop
Next
Posted

the only way is to create 2 or more arrays like this !?! Maybe there is another trick :">

#include <Array.au3>

$strComputer = InputBox("Computer Name", "Please enter the computer name" & @Lf & "you wish to get drive size from.")

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")

$colDisks = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")

$i=1

dim $Sizearray[1]

Dim $Disk[1]

For $objDisk In $colDisks

$device = StringTrimLeft($objDisk.DeviceID, 4)

$size = $objDisk.Size / 1073741824

$capacity = StringFormat("%.2f", $size)

_ArrayAdd($Disk,$device)

_ArrayAdd($Sizearray,$size)

MsgBox(0, "", "DeviceID: " & $device & @LF & "Disk Size: " & $capacity & "GB")

$i=$i+1

ReDim $Disk[uBound($Disk+$i)]

Redim $Sizearray[uBound($Sizearray+$i)]

If @error <> 0 Then ExitLoop

Next

_ArrayDisplay($Disk,"Device")

_ArrayDisplay($Sizearray,"Size")

Posted

you can use the wmi i guess

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery ("Select * from Win32_DiskDrive")
For $objItem In $colItems
    $size = $objItem.Size
Next

MsgBox(0, "DriveSize", $size)

Thanks rudika..i get the following error. please see the attached screenshot

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...