ChristianLA
Posts: 16
Joined: Wed Jun 13, 2012 10:22 pm

Custom long installation path validation faulty?

On AI 14.5 while testing the Folder dialog we are trying the following edge case:
  1. Create a long directory in Program Files, i.e., 15 New Folders at:C:\Program Files\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\
  2. Run the installer.
  3. Continue to the "Select Installation Folder" screen.
  4. Enter the long path directory into the "Folder:" text box and click "Next."
  5. Click "Install."
On some installers we get the error:

"The specified path is too long: C:\Program Files\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\Product\..."

On others the installation continues and in the middle the following error is prompted:

"Error writing to file: C:\Program Files\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\New Folder\Product\somefile.ext. Verify that you have access to that directory"


When using 19 New Folders are created at Program Files the installer display the first error only.

What will be the actual expectation for lon install paths?
Catalin
Posts: 7492
Joined: Wed Jun 13, 2018 7:49 am

Re: Custom long installation path validation faulty?

Hello Christian,

Please note that this is a limitation of the Operating System.

By default, the path that could be defined by a Windows user was 256 characters + 3 characters ("Drive:\") + 1 character (the null character that specified the end of the path) = a total of 260 characters.

Starting in Windows 10, version 1607, the MAX_PATH limitations have been removed from common Win32 file and directory functions. However, this option is not enabled by default. In order to enable it, the following registry key must be changed:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\FileSystem

In this key, the following value must be modified:

LongPathsEnabled - Changed value from false(0) to true(1)

After this step, a reboot will be required.

A test case which can be executed on a VM in order to manage the above scenario:

The second big step that must be taken in consideration here is the following element: longPathAware
which must be included in the manifest file of your application.

E.g.: <ws2:longPathAware>true</ws2:longPathAware>

Example:

Prerequisites: Visual Studio should be installed.

a. Under C:\ directory, create the following folder: a*100 (100 characters of "a")

b. Under C:\a*100, create the following folder: b*100 (100 characters of "b")

c. Under C:\a*100\b*100, create the following folder: c*50 (50 characters of "c")

d. Now try to manually create a folder. It will fail with the following error:
"The file name(s) would be too long for the destination folder. You can shorten the file name and try again, or try a location that has a shorter path."
e. The same will happen when trying to create the folder from command prompt.

f. Now modify the following registry key's value:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\FileSystem\LongPathsEnabled

from 0 to 1.

g. Restart the machine

h. The only step left is to add the "<ws2:longPathAware>true</ws2:longPathAware>" into the manifest file of our application (in our case, it is either "cmd.exe" or "explorer.exe"). By default, the cmd.exe has the earlier argument added in its manifest file. This can be seen by following the next steps:

h1. Open Visual Studio --> CTRL + O (Open File) --> System32 folder --> select cmd.exe
h2. Expand "RT_MANIFEST" and double click on "1". There we can see the above argument added

Now, if we try to create the folder from within the command prompt, we will succeed.

However, this still does not work from within the windows explorer itself. The reason behind this is the fact that explorer.exe manifest file does not contain the "longPathAware" argument. Repeat steps h1) and h2) in order to check this.

End of test case.

To be fully honest with you, I am not quite sure on what systems you are testing this scenario, as I have tested it with the exact given path (x15 New Folder) and everything worked as expected on Windows 10 (since the given path has only 182 characters).

Hope this information will be of help for you.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”