3

I want to run this command and capture the output:

fsutil fsinfo volumeInfo C:

But unless I open a cmd.exe manually "as administrator", it won't execute the command for some absurd reason. This means that it cannot be run from PHP CLI.

What is a different, non-stupid way of getting this information? And why is the fsutil command requiring administrative privileges?

Please note that I've spent ages of my life just trying to get PHP CLI to run as administrator for this kind of thing to work, but it never does work. All "workarounds" I've heard are insane and make my skin crawl.

Advit
  • 61

3 Answers3

5

wmic doesn't require administrator elevation.

To get all disks :

wmic volume get DriveLetter,FileSystem

To list one disk (D) :

wmic volume where DriveLetter='D:' get FileSystem
harrymc
  • 498,455
4

Here is how to achieve the same action in WMI using PowerShell since wmic is being deprecated. To get just D:, use the following command (Get-WmiObject).

Get-WmiObject -Class Win32_Volume | Where-Object {$_.DriveLetter -eq "D:"}

To get all drives, use the following command:

Get-WmiObject -Class Win32_Volume

If you want to see less output and find out just the file system associated with each drive, you can also use this command to select only the drive letter and filesystem properties from the volume objects:

Get-WmiObject -Class Win32_Volume | Select-Object -Property DriveLetter,FileSystem
2

Try wmic volume get caption,filesytem
And filter the output for the drive-letter that you want.

Does not require admin rights.

Tonny
  • 33,276