Archive: Slashes in a file name


Slashes in a file name
It is legal to have a file name in the form Delta/Gamma but the slash is apparently removed at some point with NSIS. Mostly, this is affecting shortcuts as in:

!define PRODUCT_NAME Delta/Gamma
...
...
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME_N} Help.lnk" "$INSTDIR\Delta.chm"

The resulting shortcut is named "DeltaGamma Help".

I tried using Delta\/Gamma and that did not work. Any other suggestions?


\ / * : " < > | are not valid in filenames on windows


Partly right
While backslashes aren't legal, the forward slash character (0x2f) is legal. It is one of those niggling annoyances when trying to do things cross-platform.

If it was treated as an invalid character in NSIS, that might be OK, depending. Instead in many places it is apparently converted to a backslash.

I managed to get around much of this with constructing the name with a backslash and converting backslashes to forward slashes at install time. The one place that this isn't working is CreateShortcut and Rename.

For example, I have a variable $SlashName which does have the forward slash in it. However, the instruction

CreateShortcut "$DESKTOP\$SlashName.lnk" "$INSTDIR\MainProgram.exe"

results in not Delta/Gamma but DeltaGamma.

This is working elsewhere, with WriteRegKey and the like. So I think maybe I can rename it.

Rename "$DESKTOP\DeltaGamma.lnk" "$DESKTOP\Delta/Gamma.lnk"

The correct name (with the slash) is recorded in the Details pane with slashes, but the actual file name has the slash removed.

This is somewhat frustrating in that I am trying to convert a working installer written with Wise Install. Absolutely, we have slashes in these names today. I'm not sure changing the name of the product in the Start menu and on the desktop is going to work.

I certainly do understand that it isn't nice to have file names with slashes in them because they are difficult to share between Windows and Linux or OS X. But this is an established Windows product and these names are limited to the Start menu, desktop and a few places in the registry.


the registry is one thing, the file system is another, you can't have a file or folder name with / in it, it is that simple.

http://img166.imageshack.us/img166/5...pathxn5.th.png