PDA

View Full Version : LongPathToShort function



Jennifer
07-23-2002, 02:21 PM
I'm trying to convert the value of a directory property from long format to a short format using the function LongPathToShort.

I do an MsiGetProperty to get the value of the directory property and what is returned is what I use as the parameter for the LongPathToShort function. But this doesn't work. Why?
If I use the example code for the LongPathToShort function it works.
Has anyone had trouble with this function?

TIA
jennifer

RobertDickau
07-23-2002, 02:51 PM
One thing mentioned on the LongPathToShortPath page is that the directory has to exist before it can be converted to a short path...

Jennifer
07-24-2002, 04:07 PM
My environment variables that reference a path location must be converted from a long path format to a short path format. I was told by InstallShield that since the Environment Variables view does not make this conversion I can create a script and use the LongPathToShort function. But this function only works if the directory path already exists. If the directory path I'm going to convert is the installation directory then it will never exist before the installation. What is InstallShield's recommendation for creating an environment variable that references a short path to the installation directory? This is only a problem with 98/ME. What does everyone else do to handle this problem? Will I have to write a scipt that creates all my environment variables?

Thanks,
Jennifer

RobertDickau
07-24-2002, 04:53 PM
The problem, as you say, is that short-path functions require the directory to exist, which won't ordinarily happen until deferred execution, but properties can be set only during immediate execution.

The best solution I've heard of is to create a custom action that creates INSTALLDIR with a custom action, gets its short name (and sets SHORTINSTALLDIR, which is used in the Environment table), and then deletes INSTALLDIR, all during immediate execution; it gets ugly, though, if INSTALLDIR creates multiple levels of new subdirectories, each of which needs to be deleted by the custom action...

LewisQ
07-24-2002, 05:04 PM
It is interesting to point out that the fact that the folder must exist is not an "IS Thing". It is rather an "OS thing". We burned a lot of brain cells with this problem until we moved away from 9x/Me...

Jennifer
07-24-2002, 05:07 PM
I guess I knew in the end I would have to end up writing a rather complicated script function. I was just hoping for a more eloquent solution.
Thank you for your replies.

Jennifer

matt.raffel
03-31-2003, 01:31 PM
LongPathToShortPath fails on all OSes. This is not an OS problem but an installshield problem. It fails just as easily (for me at least) on XP Pro.