digitalworld Posted January 26, 2006 Posted January 26, 2006 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
rudika Posted January 26, 2006 Posted January 26, 2006 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 big_daddy Posted January 26, 2006 Moderators Posted January 26, 2006 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 big_daddy Posted January 26, 2006 Moderators Posted January 26, 2006 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
Micha1405 Posted January 27, 2006 Posted January 27, 2006 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") My TrayToolBar
digitalworld Posted January 31, 2006 Author Posted January 31, 2006 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now