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
- Verify the path is a junction first with Directory.IsMountPoint (or GetLinkTargetInfo) before calling DeleteJunction.
- Use Directory.Delete on regular directories and reserve DeleteJunction for actual mount points.
- Distinguish reparse tag: check attributes for FILE_ATTRIBUTE_REPARSE_POINT and the mount-point tag.
- 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
- Use DeleteJunction only on paths created via CreateJunction or mklink /J
- Distinguish junctions from symlinks (different reparse tags)
- Never call DeleteJunction on the junction's target directory
- Validate reparse-point attributes before link-removal calls
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
- ERROR_DIR_NOT_EMPTY
- ERROR_ALREADY_EXISTS
- ({0}) The target directory is a file, not a directory: [{1}]
- The target directory is a file, not a directory: [{0}]
- volumeGuid
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/cdf4fe91535ef9be.
Report an issue: GitHub.