Sign in to follow this  
Followers 0
skyteddy

How can I count the installed harddisks?

15 posts in this topic

Hello,

how can I count the installed harddisks (not partitions) in my system? DriveGetDrive doesn't help.

And is it possible to get the manufacturer and the serialnumber of the harddisks?

Mank thanks in advance!

skyteddy

Share this post


Link to post
Share on other sites



thank you, but it don't really helps. _ComputerGetDrives uses DriveGetDrive(). So, I get the partitions and not the harddisks.

greetings

skyteddy

Share this post


Link to post
Share on other sites

thank you, but it don't really helps. _ComputerGetDrives uses DriveGetDrive(). So, I get the partitions and not the harddisks.

greetings

skyteddy

Calls to DiskPart.exe from a command line will get you closer, but still can't see past logical disks on a RAID controller to the 'real' HDDs. Not an issue for most desktops. This might suffice for you.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Calls to DiskPart.exe from a command line will get you closer, but still can't see past logical disks on a RAID controller to the 'real' HDDs. Not an issue for most desktops. This might suffice for you.

:)

DriveGetDrive(). gives the partions and yu may have many partions in one disk .

but the following script reads the caption of each disk on your computer . and you may identify the number of disks.

then you have to eliminate the removable disks.

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_DiskDrive") 
For Each objItem in colItems 
    
    Wscript.Echo "Caption: " & objItem.Caption
Next

Share this post


Link to post
Share on other sites

DriveGetDrive(). gives the partions and yu may have many partions in one disk .

but the following script reads the caption of each disk on your computer . and you may identify the number of disks.

then you have to eliminate the removable disks.

strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_DiskDrive") 
For Each objItem in colItems 
    
    Wscript.Echo "Caption: " & objItem.Caption
Next
What I have to include first? I get a lot off error if I run this code.

Skyteddy

Share this post


Link to post
Share on other sites

$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") 
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_DiskDrive") 
For $objItem in $colItems 
    MsgBox(0,"Drive", "Caption: " & $objItem.Caption)
Next


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") 
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_DiskDrive") 
For $objItem in $colItems 
    MsgBox(0,"Drive", "Caption: " & $objItem.Caption)
Next

Skyteddy!

gafrost s translation to autoit eliminates the errors.

I thougt you would translate it , which was easy !

Share this post


Link to post
Share on other sites

$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") 
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_DiskDrive") 
For $objItem in $colItems 
    MsgBox(0,"Drive", "Caption: " & $objItem.Caption)
Next
Thank you very much to all! Now it works and all my harddisks are found! :-)

many greetings from germany!

skyteddy

Share this post


Link to post
Share on other sites

Thank you very much to all! Now it works and all my harddisks are found! :-)

many greetings from germany!

skyteddy

a bit modification , to identify interface and size

$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") 
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_DiskDrive") 
For $objItem in $colItems 
    MsgBox(0,"Drive", "Caption: " & $objItem.Caption)
   MsgBox(0,"Drive", "Interface: " & $objItem.InterfaceType)
    MsgBox(0,"Drive", "Size: " & $objItem.Size)
    Next

Share this post


Link to post
Share on other sites

this is better .... skyteddy

$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") 
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_LogicalDisk") 
For $objItem in $colItems 
    MsgBox(0,"Drive", "Caption: " & $objItem.Caption)
    MsgBox(0,"Drive", "Interface: " & $objItem.DriveType)
    MsgBox(0,"Drive", "Size: " & $objItem.Size)
    Next

Share this post


Link to post
Share on other sites

this is better .... skyteddy

$strComputer = "." 
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") 
$colItems = $objWMIService.ExecQuery( "SELECT * FROM Win32_LogicalDisk") 
For $objItem in $colItems 
    MsgBox(0,"Drive", "Caption: " & $objItem.Caption)
    MsgBox(0,"Drive", "Interface: " & $objItem.DriveType)
    MsgBox(0,"Drive", "Size: " & $objItem.Size)
    Next

better than what?

The tool is to help them get the info they want about just about any wmi query, lets them know what info they can collect.

Was just pointing it out to the user for future reference, something they might learn from.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

better than what?

The tool is to help them get the info they want about just about any wmi query, lets them know what info they can collect.

Was just pointing it out to the user for future reference, something they might learn from.

gafrost ! What i mean is better than the previous scripts as it returns the drive letters

and so on ....

I never know the link which you posted Exists in autoit ! Thanks for your post .

Share this post


Link to post
Share on other sites

Thanks to all. My aim was only to create shortcuts on the desktop with argumtens hda, hdb, ... for the smartmontools. The tiny script works now. :-)

And thank you for all the additional information. there are very interesting.

greetings

skyteddy

Ps: does anyone know how I can aktivate and deaktivate toolbars? I find a way to open the menu and with send("t") I can aktivate oder deaktivate the toolbar begin with "T"rue Launch Bar, but I can't check before if is aktivated or not. The second problem is, that "t" is used for e.g. "T-DSL Manager" or "True Launch Bar". How can I handle it?

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0