🐍 Python 3.10+

Check "Enable Win32 Long Paths" Status (Python)

Reads the registry value behind the "Enable Win32 Long Paths" tweak via winreg to confirm whether it's applied.

By WindowsScripting.com · 633 B
check_enable_long_paths_status.py
#!/usr/bin/env python3
"""
check_enable_long_paths_status.py

Checks whether "Enable Win32 Long Paths" is currently applied.

Usage:
    python check_enable_long_paths_status.py
"""

import winreg


def main() -> None:
    try:
        key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\FileSystem")
        value, _ = winreg.QueryValueEx(key, "LongPathsEnabled")
        winreg.CloseKey(key)
        print(f"Current value of 'LongPathsEnabled': {value}")
    except FileNotFoundError:
        print("'LongPathsEnabled' is not set (using the Windows default).")


if __name__ == "__main__":
    main()