I have a batch file that needs to check the filesystem and choose options for a program it's running based on the filesystem (which could be NTFS or FAT32 in this environment). For Windows systems I have admin privileges on, I can use 'fsutils fsinfo' to get filesystem info - but I have users without admin privileges that may need to run this batch file, and machines I may not necessarily have admin privileges to, either. Is there an equivalent to 'fsutils fsinfo' that can get (but obviously not write, as fsutils can) file system info for a non-admin user?

  • Look at this stackoverflow question. stackoverflow.com/questions/6995813/… – maudam Jun 17 '15 at 16:32
  • Thank you, maudam. Doesn't get me exactly what I'm looking for in just a batch file (I hate to rely on generating an error to get the answer), but I think I can make the vbs version in that link work. Endgame is the same. – Trashman Jun 17 '15 at 16:42
  • I chose JosefZ's answer as it addressed my original question (better than my own answer), doing this entirely within a batch file and further without relying on error catching to do so. I do, however, appreciate the help from Maudam and the VBS based answer from paxdiablo via Maudam's link. – Trashman Jun 17 '15 at 19:15

Code snippet:

for /F %%G in ('
    wmic path win32_volume where "Caption='C:\\'" get FileSystem /value^|findstr "="
  ') do for /F %%g in ("%%~G") do set "_%%~g"
set _FileSystem


==>for /F %G in ('wmic path win32_volume where "Caption='C:\\'" get FileSystem /value
^|findstr "="') do @for /F %g in ("%~G") do @set "_%~g"

==>set _FileSystem


Resources (required reading):

Edit to get file system for all live drives:

rem SETLOCAL enableextensions
for /F %%X in ('
    wmic path Win32_LogicalDisk get caption /value^|findstr "="
  ') do for /F "tokens=2 delims==:" %%x in ("%%~X") do (

  for /F %%G in ('
      wmic path win32_volume where "Caption='%%~x:\\'" get FileSystem /value^|findstr "="
    ') do for /F %%g in ("%%~G") do set "_%%~x-%%~g"

set _


==>set _
Environment variable _ not defined


==>set _

  • I like that this is a pure batch file implementation. I can take this, and I can generate the file system by replacing what's inside the single quotes after "Caption=" with one of my drive letters. One issue, the way this will get run, it's actually being based on a file and what drive the file is on. I used the left(arg,2) in my VBS script to just take just the drive letter. Here, It has to have two '\' after the drive letter. If a full path is being passed as a parameter to this batch file, how do I get it to check the drive properly? (the ways i'm trying keep getting errors) – Trashman Jun 17 '15 at 18:54
  • 1
    Well, I just looked at your list of resources and saw I just needed to replace C: with %~d1 – Trashman Jun 17 '15 at 19:10

Here's an alternate solution that also worked for me, though it wasn't done purely with a batch file:

In VBS File 'GetFileSys.vbs':

Set args = Wscript.Arguments
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colVols = objWMIService.ExecQuery ("select * from Win32_LogicalDisk")

For Each arg in args
    For Each objVol in colVols
        if objvol.Name = left(arg,2) then
            Wscript.Echo objVol.FileSystem
        end if

(The top portion I borrowed from paxdiablo via the link provided by Maudam, https://stackoverflow.com/questions/6995813/how-can-i-use-batch-to-determine-if-a-computer-is-using-fat32-or-ntfs , then adapted to my needs)

Then, In the batch file, I called the VBS file with cscript like so:

cscript //NoLogo GetFileSys.vbs %1 %2 %3



(I didn't even realize my system was using ReFS until I ran this)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.