Search code examples
windowsdirectorybatch-filejunction

How can I make a batch file discover if a directory is actually a Junction?


I'm writing a Batch file (.bat) and I couldn't find a way to discover if a given directory I have the path to is a real directory or a Junction (created on Windows 7 by using mklink /j). Can anyone point me in the right direction?


Solution

  • This is a lousy technique but fsutil reparsepoint query path to file will fail (%ERRORLEVEL% will be 1) if the file is not a junction and succeed (%ERRORLEVEL% will be 0) if it is one. The other problem with this is fsutil wants you to be an administrator. Additionally, not all reparse points are directory junctions.