Skip to content
⌘ NSIS Forum Archive

$InstDir with GetFullPathName /SHORT question

9 posts

coderwolf#

$InstDir with GetFullPathName /SHORT question

I am at a bit of a loss here. I have the following code:

Page directory "" "" fnc_InstDir_AfterShow

Function fnc_InstDir_AfterShow
MessageBox MB_OK "$InstDir"
GetFullPathName /SHORT $CMPC_RootPath_Short $InstDir
MessageBox MB_OK "$CMPC_RootPath_Short"
FunctionEnd
The first MessageBox is showing the $InstDir correctly. I have other "GetFullPathname /SHORT" calls working correctly with other variables using the same syntax . But for some reason, the second MessageBox comes out blank. What am I missing here?
aerDNA#
Empty string indicates that GetFullPathName has failed. You're probably trying to get a short path for a dir that hasn't been created yet.
Anders#
Short paths should only be used for compatibility with 16-bit programs and buggy applications. Short name generation can be turned off so not every filename will have one...
aerDNA#
You can check for NtfsDisable8dot3NameCreation. It doesn't tell you the state at the time an existing dir was created but it can tell you whether you'll be able to create new short paths. It should only be used when it can't be avoided, that much is for sure.
coderwolf#edited
Originally Posted by Anders View Post
Short paths should only be used for compatibility with 16-bit programs and buggy applications. Short name generation can be turned off so not every filename will have one...
This is an auto-configuration wrapper for a DOS emulation program. I am getting the path in a way that the DOS emulator would know what it is in the main OS(windows 7). This information is (in the installer process) written to its config file as a "mounted" drive.

Originally Posted by aerDNA View Post
You can check for NtfsDisable8dot3NameCreation. It doesn't tell you the state at the time an existing dir was created but it can tell you whether you'll be able to create new short paths. It should only be used when it can't be avoided, that much is for sure
As you can see from what my main goal is above, it is unavoidable. After a bit of investigation, under windows 7 "NtfsDisable8dot3NameCreation" is a volume based setting. I have looked at it and it is on for the volume in question. As for your earlier idea about it being a directory that has not been created at that point in time, I will have to investigate that further.
aerDNA#edited
I tried Kernel32::GetVolumeInformation but it always returns 255 for lpMaximumComponentLength, regardless of reg entry. It just tells you if FS supports long names, not if Windows is creating short names, so that's useless. In the end, GetFullPathName /SHORT is as good a check as any. If it fails and you're sure it's an existing path, it means 8.3 creation is disabled. At that point there's not much you can do but inform the user.
coderwolf#
Originally Posted by Anders View Post
Short paths should only be used for compatibility with 16-bit programs and buggy applications. Short name generation can be turned off so not every filename will have one...
It appears that the Directory was not created and that was the issue. I added a line before I ran the /short line. After I did that the returned variable was not blank. This is an internally used install file, so I believe I can trust that the machines will have a standard configuration with C drive set to support 8.3 filename format, so I am going to just give it a very basic ${If} Short_Path == "" -> MessageBox structure (as I am not proficient enough with this installer to get that deep atm).
coderwolf#
If the path is not set, is there a command to auto "rollback" the installation steps done at that point. Or is my only option to code a rollback using a step by step code at that point?