- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- How to execute a Deferred PowerShell Custom Action only on install?
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I've added a PowerShell custom action which adds a Firewall rule to the system. However, it is always being added, on install, re-install and uninstall. Is there a public property that I can use to determine whether the application is installed for the first time on the system?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank you for your reply.
You are welcome, @gomochainstall! I'm happy to hear that you've got it working.
If you are using a Basic MSI project or an InstallScript MSI project, not an InstallScript project, you could try using the REMOVE public MSI property in the following condition:
REMOVE~="ALL"
That condition will only evaluate to true only during uninstall.
Please give this condition a try, rebuild your project, then retest this issue. Does this issue still occur?
Please let us know if you have any questions or concerns. Thanks!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi @gomochainstall,
Thank you for your post.
If you are using a Basic MSI project or an InstallScript MSI project, not an InstallScript project, you could try using the Installed private MSI property.
Here is a link to the official Microsoft documentation about the Installed MSI property:
https://docs.microsoft.com/en-us/windows/win32/msi/installed
I understand that you requested a public property, but the Installed property is typically the property used for this type of condition.
The condition for a first-time install would be: NOT Installed
because you would be checking whether the product has already been installed. If the installer is running as a first-time install then the Installed property will not be set. Hence, you would be checking if the Installed property is not set.
Here is a link to our Introducing the Installer Cheat Sheets blog post, which has a link to a Common MSI Conditions Cheat Sheet:
https://www.revenera.com/blog/software-installation/installer-cheat-sheet-series/
Hope this help.
Please let us know if you have any questions or concerns. Thanks!
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank you! I've got it working. But now I have a different question, what if I want to remove the firewall rule only on uninstall? The 'Installed' property will also have a value on a reinstall so I can't just remove it when 'Installed' has a value.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank you for your reply.
You are welcome, @gomochainstall! I'm happy to hear that you've got it working.
If you are using a Basic MSI project or an InstallScript MSI project, not an InstallScript project, you could try using the REMOVE public MSI property in the following condition:
REMOVE~="ALL"
That condition will only evaluate to true only during uninstall.
Please give this condition a try, rebuild your project, then retest this issue. Does this issue still occur?
Please let us know if you have any questions or concerns. Thanks!
