taniax
Posts: 3
Joined: Mon Oct 29, 2018 10:55 am

Retrieve custom directory path with whitespace to output.txt

Hello everybody,

Can you tell me how can i retrieve a custom directory path with whitespace to an output.txt for exemple
ai.PNG
ai.PNG (10.43 KiB) Viewed 3224 times
Path edit should be : C:\Program Files (x86)\Application Verifier
or : C:\Program Files (x86)\Application Verifier\out put.txt

i would like retrieve this directory path / file directory and write it into a *.txt file

Can you please, help me ?

Thanks you so much for your answers

Sorry for my english
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Retrieve custom directory path with whitespace to output.txt

Hello and welcome to our forums,

What you want to achieve can be done through a custom action.

First of all, the path from the "Data to export" field is saved into an installer property. Properties are global variables used by Windows Installer during an installation process. Properties can be used inside Formatted Type fields with the format [PROPERTY] and they will be replaced at install time with the value associated with the property's name.

For instance, to check the name of the property which stores your path, you can simply open your project (.aip file) --> travel to "Dialogs" page --> click on the dialog which contains the "Data to export" field --> click on the "Path Edit" field as in your sent screenshot and, on the right pane, under "Properties" you can check the "Property Name" associated with that field.

Now that we know the property which stores the path, all we have to do is to output it into a text file. To do so, please proceed as it follows:

- Go to "Custom Actions" page and add a "PowerShellScriptInline" custom action with sequence. To add a custom action with sequence, all you have to do is to press the "Add custom action with sequence" button which is place on the right side of the custom action's name.

- After doing so, under "#Your code goes here" comment, please add the following lines:

Code: Select all

$prop = AI_GetMsiProperty YOUR_PROPERTY
Out-File -FilePath C:\out.txt -InputObject $prop
Important: Replace "YOUR_PROPERTY" with the name of the property which is associated with the "Path Edit" field. You can also change the file path of the output text file.

Under "Execution Stage Condition", you can uncheck the "Uninstall" and "Maintenance" options, so your custom action will only be run during the install process.

Please let me know if this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
taniax
Posts: 3
Joined: Mon Oct 29, 2018 10:55 am

Re: Retrieve custom directory path with whitespace to output.txt

Hello thanks you so much for your answer !

Actualy this is not worked like i would like .

Can you tell me how can i remove "Return code: 0" and "Script output: "

and how can i concatenate a string with variable ?

For example :
ai.PNG
ai.PNG (13.29 KiB) Viewed 3213 times
Output file expected :

Code: Select all

ShowConsole=True
WinbooksFolder=""C:\Winbooks\Data\PARFILUX""
WinbooksFile=""PARFILUX_ACT.DBF""
EBPFolder=""C:\Program Files\EBP\Invoicing9.0FRBE40""
EBPFile=""C:\Users\guillaume\Documents\EBP Demo Gestion 9.0 BE Ligne Open Line.ebp""
ExportModel=testimport
Can you tell me witch kind of language this script function use ? So i can learn script by myself

Sorry if my english is not correct .
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Retrieve custom directory path with whitespace to output.txt

Hello,

First of all, you do not need to worry about the "Return Code" and "Script Output", as those are only shown upon pressing the "Test script" button from the "Custom Actions" page. Upon running the setup, those will not appear in the output text file.

In order to concatenate a string with a variable, you can proceed as it follows (using the "+" [plus] operator):

Code: Select all

$string = 'Hello there, how are you?'
$string1 = 'I hope you are doing well.'
Out-File -FilePath C:\hello.txt -InputObject ($string + " " +$string1)
The output of the above code will be: "Hello there, how are you? I hope you are doing well."
Can you tell me witch kind of language this script function use ? So i can learn script by myself
As the name of the custom action suggests, it is using the PowerShell language.

Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
taniax
Posts: 3
Joined: Mon Oct 29, 2018 10:55 am

Re: Retrieve custom directory path with whitespace to output.txt

Thanks you so much for your reply !
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Retrieve custom directory path with whitespace to output.txt

You're always welcome.

I am glad I could help.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”