och
Posts: 9
Joined: Wed Jan 07, 2015 12:41 pm

Pass Windows Installer Property to Powershell script

Hi,

I want to pass Windows Installer Property (APPDIR) to Powershell script Custom Action. I checked http://www.advancedinstaller.com/user-g ... ell-script but it doesn't work for me. Or maybe I am using it wrong.
In my "Script Parameters" input box i filled

Code: Select all

-appDir [APPDIR]
and in my Powershell script I am checking the value

Code: Select all

echo $appDir >> "C:\install.log"
but nothing is written out.

Also AdvancedInstaller generates EXE instead of MSI for my project if that makes any difference.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Pass Windows Installer Property to Powershell script

Hello,

Please note that you also need to update the param section of the script.
So, in the Script section you should have something like that:

Code: Select all

param($appDir)
echo $appDir >> "C:\install.log"
You can also take a look on the Get value TextBox Dialog with PowerShell Script forum thread which debates a similar subject.

Please let us know if the behaviour still persist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
och
Posts: 9
Joined: Wed Jan 07, 2015 12:41 pm

Re: Pass Windows Installer Property to Powershell script

It doesn't work.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Pass Windows Installer Property to Powershell script

Hello,

I'm not sure why you encountered the this behavior.
In order to have a better view about this, can you please send us the .AIP (project file) to support at advancedinstaller dot com so we can investigate it? If it contains confidential information you can send us a small test project which reproduce this behaviour.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
och
Posts: 9
Joined: Wed Jan 07, 2015 12:41 pm

Re: Pass Windows Installer Property to Powershell script

Ok, I have sent it. Hope it'll help.
och
Posts: 9
Joined: Wed Jan 07, 2015 12:41 pm

Re: Pass Windows Installer Property to Powershell script

I got response from support and they helped me to solve it.

The problem was that the param($appDir) must be the first line in the script. So I changed from

Code: Select all

date >> "C:\install.log"
param($appDir)
echo "appDir 1" >> "C:\install.log"
echo $appDir >> "C:\install.log"
echo "appDir 2" >> "C:\install.log"
...
to

Code: Select all

param($appDir)
date >> "C:\install.log"
echo "appDir 1" >> "C:\install.log"
echo $appDir >> "C:\install.log"
echo "appDir 2" >> "C:\install.log"
...
and now it works.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Pass Windows Installer Property to Powershell script

Hello,

Thank you for posting the resolution. Certainly, this thread will be available for future users facing the same situation.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”