r/visualbasic • • Mar 13 '20

Get drive/partion information including total space, free space, make, model and if SSD or not

Hi All,

I'm trying to write a small inventory app that retrieves information about a client and sends it to a remote server. I've managed to find drive/partition information and total space/free space etc but im struggling with make/model and SSD, ideally, it would be nice to get it all at the same time rather than trying to gather from different places but I'm not sure that will be possible.

All help is greatly appreciated, thanks.

Edit: *partition in title, didn't spot it until right as I clicked save :\

5 Upvotes

7 comments sorted by

5

u/bigredluigi Mar 14 '20

You can use the Microsoft WMI Class MSFT_PhysicalDisk. The mediatype of 4 is SSD and SpindleSpeed will be 0. for more details see link. https://msdn.microsoft.com/en-us/library/windows/desktop/hh830532(v=vs.85)

1

u/Zenith2012 Mar 14 '20

Hi, not had chance to test yet but this looks very much like it should be a winner, thanks.

3

u/banshoo Mar 13 '20

There isnt an API for this.. Potentially, you might be able to read from registry, but I guess you'd need to know what your searching for.

for SSD, Im fairly sure there isnt (unless its stored in reg again?), but you could measure by read/write and infer based upon speeds.

Failing that, your looking at trying to read from device drivers entirely (a pain).. or somehow accessing hardware directly (an even greater pain)

0

u/Zenith2012 Mar 13 '20

there's a powershell command that i've found that gives you SSD or HDD:

Get-PhysicalDisk

Will have to lookup having vb.net execute a PS command and parse the results maybe.

Edit: Also thanks for your reply, was really hoping it wasn't going to be a difficult task but turns out it may be harder than I expected.

2

u/banshoo Mar 13 '20 edited Mar 13 '20

Didnt know about (well, knew about it.. but havent looked into it in any detail) powershell...

Couldnt tell you how to access it - I know it has to be run as a powershell cmd terminal for both path & elevation privileges... good luck working that one out..

likely best bet to get responses back is likely from outputting your pshell output to text & then parsing that directly

Given vb.net is definitely on the wane.. if you can control pshell from vb, this might open additional control options.

edit :

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe or %windir%\system32\WindowsPowerShell\v1.0\PowerShell_ISE.exe

might be as simple as passing parameters?

4

u/PFthroaway VB.Net Advanced Mar 13 '20

DriveInfo is likely going to help you with that. I don't know if it can tell if it's an SSD, but it definitely can tell you total/free space. I use it in my Backup application.

2

u/bigredluigi Mar 14 '20

Sometimes the old school solution is the best. Good luck with your project.