cancel
Showing results for 
Search instead for 
Did you mean: 
DjessHz
Pilgrim

How to run a powershell script from msi before install

Hi,

I'm trying to run a PowerShell script before installing my application via the MSI package
I would like my script to run directly when the user is double clicking on the MSI

I have already tried to do this :

On Behavior and Logic -> Custom actions and Sequences
Custom actions -> New PowerShell -> Stored in Binary Table

On Common table :
PowerShell Script File Name -> Path to my ps1 script
Return Processing -> Synchronous (Check exit code)
In-Script Execution -> Immediate execution
Execution scheduling -> Always execute

Install Exec Sequence ->

But my script is not running when my MSI is launched

Did I forgot something ?
Thank you
Labels (1)
Tags (3)
0 Kudos
3 Replies
chad_petersen
Occasional contributor

Re: How to run a powershell script from msi before install

The Exec Sequence does not happen until you get all of the way through the UI Sequence. It sounds like you've got it scheduled to run in the wrong sequence for what you are wanting.

Try changing it to the UI Sequence instead.

Chad
0 Kudos
DjessHz
Pilgrim

Re: How to run a powershell script from msi before install

chad.petersen wrote:
The Exec Sequence does not happen until you get all of the way through the UI Sequence. It sounds like you've got it scheduled to run in the wrong sequence for what you are wanting.

Try changing it to the UI Sequence instead.

Chad


I have already tryed to change the UI Sequence, it's not working

Any other idea ?
0 Kudos
Highlighted
DjessHz
Pilgrim

Update

Ok, I found the problem (really strange by the way...)

My script was not working because it needed another script to work..
As my original script was not working, I created a new one (another powershell script) which was only displaying a form :

[CODE][System.Windows.Forms.MessageBox]:Smiley Frustratedhow("My Custom Action","Hello", 0, 64)[/CODE]

I removed my original script from the sequences and I have been trying to run my test script at all positions in the UI and Exec sequences
With no success..

So, I tried to run my first script again, but I forgot to desactivate my test script
And, miraculously, it works !

I don't know if it is an Installshield problem or maybe a wrong defined or forgotten parameter

But the fact is, in order to run a powershell script (before install process in my case) follow these steps:

For the new script
1) Create a new Powershell custom action (in addition to your script)
2) In the common tab :
PowerShell Script File Name -> Path to an empty script ps1
Return Processing -> Synchronous (Check exit code)
In-Script Execution -> Immediate execution
Execution scheduling -> Always execute

Install UI Sequence ->
Install Exec Sequence ->
+ Install Exec Condition -> Not Installed

For your custom script
In the common tab :
PowerShell Script File Name -> Path to your script ps1
Return Processing -> Synchronous (Check exit code)
In-Script Execution -> Immediate execution
Execution scheduling -> Always execute

Install UI Sequence ->
Install Exec Sequence ->
+ Install Exec Condition -> Not Installed

If, for example, you add a form in the new script, it will not be executed, but allows the second one to run..

If someone has an explanation, feel free to share !
Thank you and enjoy
0 Kudos