0

Followed the steps given below to enable long paths and rebooted the machine

  • Press Win + R keys on your keyboard and type regedit then press Enter.
    Registry Editor will be opened.

  • Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem

  • Edit LongPathsEnabled and set it to 1.

  • Press Win + R keys on your keyboard and type gpedit.msc then press Enter.
    Group Policy Editor will be opened.

  • Go to Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> Filesystem, then enable the Enable Win32 long paths option.

  • Restart machine.

Executed the below program to check if the file gets created in the already existing folder structure C:\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz\abcdefghijklmnopqrstuvwxyz

int main()
{
    HANDLE h = CreateFileA(
    "C:\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\abcdefghijklmnopqrstuvwxyz\\012345678901234567890123456789.txt",
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    CREATE_NEW,
    FILE_ATTRIBUTE_TEMPORARY,
    NULL);
    
    if (h == INVALID_HANDLE_VALUE) { DWORD err = GetLastError(); printf("err %dn", err); getchar(); return 1; }
    printf("Created\n");
    getchar();
    
    return 0;
}

The above program failed to create the file and produced the following output

err 3

The same program worked in MS Windows 2016

What additional thing needs to be done in Windows 2019 for long paths to work?

Machine details:
Windows Server 2019
Microsoft Windows Server
Version 1809 (OS build 17763.316)

greybeard
  • 2,249
  • 8
  • 30
  • 66
Bhaskar V
  • 1
  • 1
  • 1
  • You have to declare long path readiness in your manifest. – Raymond Chen Feb 14 '22 at 05:37
  • Where to find the manifest file – Bhaskar V Feb 15 '22 at 12:10
  • 1
    Does this answer your question? [How to enable "Long Path Aware" behavior via manifest in a C++ executable?](https://stackoverflow.com/questions/53918205/how-to-enable-long-path-aware-behavior-via-manifest-in-a-c-executable). I just searched for "long paths manifest". – Raymond Chen Feb 15 '22 at 14:26

0 Answers0