Question

We have a service (runs as the SYSTEM user) which uses WMI to get the volume serial number of the drive Windows is installed. However, we have a client whose WMI security is too restrictive and we cannot query the volume serial number in this way.

Rather than learning the ins-and-outs of WMI security permissions, I wanted to use the native Win32 function GetVolumeInformation to get this information. However, I don't know if this call uses WMI to get this info from the drive, or if it just uses something which is set in the registry (or some other easily accessible place) where it can be changed by a normal user (I know the volume serial can still be changed if you really know how).

Is GetVolumeInformation a viable workaround for circumventing WMI? And if not, what is the best way to get this information in C# without using WMI calls?

Was it helpful?

Solution

I bit the bullet and ended up just making a call into the Win32 API to GetVolumeInformation (linked above in the question). When you retrieve the volume serial using this function, you must remember to convert the decimal number to hex if you want the same value that the "vol" command shows in the command prompt.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top