peass-ng/PEASS-ng · error · NotAReparsePointException

ERROR_NOT_A_REPARSE_POINT

ERROR_NOT_A_REPARSE_POINT

Error message

The directory is not a mount point: [{0}]

What it means

DeleteJunctionCore throws NotAReparsePointException with message 'The directory is not a mount point: [{0}]' and underlying Win32 error ERROR_NOT_A_REPARSE_POINT when the given junctionPath exists but is a plain directory without a mount-point/junction reparse tag. Only reparse points of type mount point can be deleted as junctions, so AlphaFS validates fsEntryInfo.IsMountPoint before issuing the native removal.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Filesystem/Directory Class/Directory Core Methods/Directory.DeleteJunctionCore.cs:65

      [SecurityCritical]
      internal static void DeleteJunctionCore(KernelTransaction transaction, FileSystemEntryInfo fsEntryInfo, string junctionPath, bool removeDirectory, PathFormat pathFormat)
      {
         if (null == fsEntryInfo)
         {
            if (pathFormat != PathFormat.LongFullPath)
            {
               Path.CheckSupportedPathFormat(junctionPath, true, true);

               junctionPath = Path.GetExtendedLengthPathCore(transaction, junctionPath, pathFormat, GetFullPathOptions.CheckInvalidPathChars | GetFullPathOptions.RemoveTrailingDirectorySeparator);

               pathFormat = PathFormat.LongFullPath;
            }


            fsEntryInfo = File.GetFileSystemEntryInfoCore(transaction, true, junctionPath, false, pathFormat);

            if (!fsEntryInfo.IsMountPoint)
               throw new NotAReparsePointException(string.Format(CultureInfo.InvariantCulture, Resources.Directory_Is_Not_A_MountPoint, fsEntryInfo.LongFullPath), (int) Win32Errors.ERROR_NOT_A_REPARSE_POINT);
         }
         

         pathFormat = PathFormat.LongFullPath;


         // Remove the directory junction.

         using (var safeHandle = OpenDirectoryJunction(transaction, fsEntryInfo.LongFullPath, pathFormat))

            Device.DeleteDirectoryJunction(safeHandle);


         // Optionally the folder itself, which should and must be empty.

         if (removeDirectory)

            DeleteDirectoryCore(transaction, fsEntryInfo, null, false, false, true, pathFormat);

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Verify the path is a junction first with Directory.IsMountPoint (or GetLinkTargetInfo) before calling DeleteJunction.
  2. Use Directory.Delete on regular directories and reserve DeleteJunction for actual mount points.
  3. Distinguish reparse tag: check attributes for FILE_ATTRIBUTE_REPARSE_POINT and the mount-point tag.
  4. If the intent was to remove a symlink, use the appropriate symlink-removal API instead.

Example fix

// before
Directory.DeleteJunction(path); // fails if path is a normal dir or symlink
// after
if (Directory.Exists(path) && Directory.IsMountPoint(path))
    Directory.DeleteJunction(path);
else
    Directory.Delete(path, true); // handle normal directories separately
Defensive patterns

Strategy: validation

Validate before calling

if (!Directory.IsMountPoint(path))
    throw new InvalidOperationException($"{path} is not a junction/mount point");

Type guard

bool IsJunction(string p) => Directory.Exists(p) && Directory.IsMountPoint(p);

Try / catch

try { Directory.DeleteJunction(path); }
catch (NotAReparsePointException) { Directory.Delete(path, true); }

Prevention

When it happens

Trigger: Calling Directory.DeleteJunction / DeleteJunctionTransacted on a normal (non-reparse) directory; passing a symbolic link instead of a junction (symlinks have a different reparse tag); passing the junction's TARGET path rather than the junction path itself.

Common situations: Confusing junctions and symbolic links in Windows (mklink /J vs mklink /D); cleanup scripts that blindly call DeleteJunction on every directory in a tree; path typos pointing to the real folder behind the junction.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/cdf4fe91535ef9be. Report an issue: GitHub.