Convert Path command

Got a problem you cannot solve? Try here.
Post Reply
Frank
Posts: 59
Joined: Tue Oct 27, 2009 9:16 am
Location: Netherland

Convert Path command

Post by Frank »

During the installation a user can input a folder, which can be done by hand or by using a browser.
This folder can have a \ at the end of it. That's valid, but actually quite annoying when used in a command line tool.

Let me elaborate:
I'm calling a tool which replace a string in a file with another string. Using this mechanism I can use the Installer to modify configuration files.
It's called like this:

Code: Select all

MyTool.exe configfile pattern requiredValue
To handle the fact that paths can contain spaces I'm using loads of quotes ("), like so:

Code: Select all

Run Program $SUPPORTDIR$\MyTool.exe "$TARGETDIR$\MyConfigFile.xml" %DATALOC% "$PathToDataLoc$"
When executed it updates a config file that has the value c:\dataloc". Notice the "at the end, this happens because of the \.
I need to get rid of this ". I can do this by removing either the \ or stop using quotes.

I found that I can use Convert to Short Path to eliminate the use of quotes, but the results are strange.
I input "c:\my test\dataloc\" to which the Convert to Short Path responds with: q:\INSTAL~1\Release\UNCOMP~1\data
What gives? That not even close!! :o
In the manual it is suggested that the folder should already exist. In my case it doesn't, but the result is weird.
I'm using IA 12 (build Moooya.9.26.11)

I don't want the installer to create the folders. This is handled by the initializer of the installed product, besides using a DLL call to CreateDirectory can only create the 'final' directory. So if more none-existing directories are in the path, the call will fails anyhow.
Concrete question: How can I remove (if it's there) the final
By the way: I also can't use Create Folder (MSI command) since I don't want these folders to disappear after an uninstall.
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Convert Path command

Post by FrancescoT »

Dear Frank,
By the way: I also can't use Create Folder (MSI command) since I don't want these folders to disappear after an uninstall.
you can create a folder without it being removed during unistall.
This can be easly done turning ON the native engine just before any Windows Installer commd.

Example:

Code: Select all

Set Variable MYPATH to C:\test

Set Variable NATIVE_ENGINE to TRUE
Create Folder $MYPATH$
Set Variable NATIVE_ENGINE to FALSE
Using the above code, the Create folder command is not placed in the MSI database.
The command is executed immediatelly and the folder will be not removed during unistall.

Regarding the string manipulation .... to check if a slash is present at the end of your string ( ... if I haven't missed your question),
you could use PARSE STRING command.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Frank
Posts: 59
Joined: Tue Oct 27, 2009 9:16 am
Location: Netherland

Re: Convert Path command

Post by Frank »

Very cool...Is that a IA2012 feature? The whole native engine on/off?

I'm using more 'akward' scripting to copy for instance license file, but the native engine on/off would also do the trick there.

Let me go and revise my old IA code and make a mental note of this... :D

You might consider creating a sticky for this...I think more people will like this.
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: Convert Path command

Post by FrancescoT »

Dear Frank,

Native engine has been introduced with InstallAware 10.

For more details please follow IA documentation.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply