We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

AlexanderAnishchik
Posts: 18
Joined: Fri Jan 10, 2020 10:54 am

Access AI_ProgramFiles

Can I access AI_ProgramFiles value inside of Powershell Inline Script that run before installation of prerequisites? I want to rename old MariaDB folder before of installation MariaDB as prereprerequisite. But the value of property AI_ProgramFiles and custom search is empty.

Here is my script:

Code: Select all

# Block for declaring the script parameters.
Param()
$mariaDBInstalled = AI_GetMsiProperty MARIADB_DIR
Write-Output $mariaDBInstalled
$programFiles = AI_GetMsiProperty AI_ProgramFiles
$path= $programFiles +"MariaDB " + (AI_GetMsiProperty MARIADBVERSION)
Write-Output $path
$newname="Old MariaDB " + (AI_GetMsiProperty MARIADBVERSION) + "Backup"
# Your code goes here.
if((Test-Path2 $path) -AND ($mariaDBInstalled -EQ "NULL")){
Write-Output "IF SUCCESS"
		Rename-Item -Path $path -NewName newname
}
How can I achive that?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Access AI_ProgramFiles

Hello Alexander,

Could you please try to retrieve the "ProgramFilesFolder" property instead? The AI_ProgramFiles is a custom made property and I am not quite sure if you can retrieve its value.

With that being said, your script could look like this:

Code: Select all

$programFiles = AI_GetMsiProperty ProgramFilesFolder
Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
AlexanderAnishchik
Posts: 18
Joined: Fri Jan 10, 2020 10:54 am

Re: Access AI_ProgramFiles

It works but returns C:\Program Files (x86) while my application mixed 64/32. It seems like we can't fetch value of Custom Search in Pre-Install section. Is it true?
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Access AI_ProgramFiles

Hello Alexander,

The ProgramFIlesFolder property resolves based on Operating System bitness. It resolves to:

C:\Program Files

C:\Program Files (x86) -- on a 64-bit machine


If you want to set it to "C:\Program Files (x86)" on x86 machine and to "C:\Program Files", you can condition it in your script, as it follows:

Code: Select all

$versionNT64 = AI_GetMsiProperty VersionNT64

if($versionNT64 -eq ""){

$progFiles = AI_GetMsiProperty ProgramFilesFolder

}

else{

$progFiles = AI_GetMsiProperty ProgramFiles64Folder

}
VersionNT64 is a property which is set only on 64-bit machines, therefore we can use it to condition setting the value of the $progFiles variable.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
AlexanderAnishchik
Posts: 18
Joined: Fri Jan 10, 2020 10:54 am

Re: Access AI_ProgramFiles

Thanks it will help. Is it possible to use custom variables such a result of the search in Pre-Install sections? I can't access this value before prerequisites but it accessible when main installation is started.
Attachments
Screenshot_2.png
Screenshot_2.png (17.88 KiB) Viewed 3975 times
Catalin
Posts: 7853
Joined: Wed Jun 13, 2018 7:49 am

Re: Access AI_ProgramFiles

Hello Alexander,

Yes, that should be possible.

The easiest way in which you can check this is by using a MessageBox custom action which will print the result of your search.

Please follow these steps:

- in "Custom Actions" page, please add a "MessageBox" custom action without sequence (press the "Add custom action without sequence" button which is placed to the right side of the custom action's name)

- in the "Message" field of your custom action, insert the name of your property enclosed in square brackets (e.g. [RESULT_PROPERTY])

- now please go to "Dialogs" page and under "Pre-install UI", please select "WelcomePrereqDlg" dialog. After doing so, select the "Next" button and, under "Published Events" tab, click the "New..." button and add an event as it follows:

Event: Execute Custom Action
Argument: MessageBox
Condition: leave unchanged


- build and run your setup. The messagebox should print the value of the property that stores the result of your search.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”