BCUninstaller/Bulk-Crap-Uninstaller · error · IOException
Win32_Directory.Compress returned {ret}
Error message
Win32_Directory.Compress returned {ret} What it means
Thrown by FilesystemTools.CompressDirectory after invoking the WMI method Win32_Directory.Compress. It casts outParams.Properties["ReturnValue"].Value to uint and, if it is non-zero, throws IOException with the code appended. Non-zero return codes from this WMI method indicate failure (e.g. access denied, path not found, the directory is on a volume that does not support NTFS compression).
Source
Thrown at source/KlocTools/Tools/FilesystemTools.cs:125
Directory.Move(source.FullName, target.FullName);
else
{
CopyRecursive(source, target);
source.Delete(true);
}
}
public static void CompressDirectory(string dirFullName) => CompressDirectory(dirFullName, ManagementOptions.InfiniteTimeout);
public static void CompressDirectory(string dirFullName, TimeSpan timeout)
{
var objPath = "Win32_Directory.Name=" + "\"" + dirFullName.Replace(@"\", @"\\") + "\"";
using (var dir = new ManagementObject(objPath))
{
var outParams = dir.InvokeMethod("Compress", null, new InvokeMethodOptions { Timeout = timeout });
if (outParams == null) throw new ArgumentNullException(nameof(outParams));
var ret = (uint)outParams.Properties["ReturnValue"].Value;
if (ret != 0)
throw new IOException("Win32_Directory.Compress returned " + ret);
}
}
[DllImport("shlwapi.dll")]
public static extern bool PathIsNetworkPath(string pszPath);
[DllImport("kernel32.dll", EntryPoint = "CreateSymbolicLinkW", CharSet = CharSet.Unicode)]
private static extern int CreateSymbolicLink([In] string lpSymlinkFileName, [In] string lpTargetFileName,
SymbolicLinkType dwFlags);
}
}View on GitHub (pinned to 608321de98)
Solutions
- Ensure the target volume is NTFS (or ReFS where supported) before compressing.
- Run the host process elevated and confirm WMI service (winmgmt) is healthy.
- Decode the ReturnValue (e.g. 2 = access denied, 3 = path not found) and surface a meaningful error; fall back to the Win32 DeviceIoControl FSCTL_SET_COMPRESSION P/Invoke if WMI is unreliable.
Example fix
// before
FilesystemTools.CompressDirectory(@"E:\MyDir"); // E: is FAT32 -> code 11
// after: guard against non-NTFS and report the code
if (new DriveInfo(Path.GetPathRoot(dir)).DriveFormat != "NTFS")
throw new InvalidOperationException("Compression requires an NTFS volume.");
try { FilesystemTools.CompressDirectory(dir); }
catch (IOException ex) { logger.Error($"Compress failed: {ex.Message}"); } Defensive patterns
Strategy: try-catch
Validate before calling
var root = Path.GetPathRoot(dirFullName); if (new DriveInfo(root).DriveFormat != "NTFS") return; // skip non-NTFS FilesystemTools.CompressDirectory(dirFullName);
Try / catch
try { FilesystemTools.CompressDirectory(dir); }
catch (IOException ex) { logger.Warn($"Compress failed ({ex.Message}). Code may indicate access/path/FS error."); } Prevention
- Verify the target volume is NTFS before attempting compression.
- Run elevated and confirm WMI health on target machines.
- Decode ReturnValue (2 access denied, 3 not found) for actionable errors.
When it happens
Trigger: Calling CompressDirectory on a path that does not exist, is on a non-NTFS volume (FAT32/exFAT), when the process lacks SeManageVolumePrivilege / admin rights, or when WMI is broken/disabled.
Common situations: Portable apps run from FAT32 USB drives, non-elevated processes, WMI repository corruption, or paths with characters that break the WMI object path escaping.
Related errors
- Not a Windows .exe file.
- Path does not point to a valid .reg file
- Process name can't be null or empty
- Path is too short/invalid
- Minimum value must be lower than or equal to the maximum val
AI-assisted analysis of BCUninstaller/Bulk-Crap-Uninstaller@608321de98 (2026-08-13).
Data as JSON: /api/errors/aed3f43922de6a82.
Report an issue: GitHub.