I've been playing around with .MSI creation within PowerShell Studio. Under Settings \ Files-Folders I've pointed to an .EXE that displays a GUI. Under Settings \ Custom Actions I've pointed to the .EXE and used the INSTALLDIR default. I've said to Run at Installation. In my script I've tried using the & sign to point to the .EXE.
It never runs. Can you embed an .EXE within your compiled .MSI (or EXE) and have it install when the .MSI is run? Or will this only with if you have your script first copy the .exe down to the system and then run it from there?
include files inside of .EXE or .MSI
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: include files inside of .EXE or .MSI
There is no limitation on what types of files you can include in an MSI. If an exe file installed by the MSI installer, it usually is either a system limitation or a setting on the custom action.
So the exact settings you use and the version of PowerShell Studio used as well as OS information would all be helpful to diagnose the issue.
Additionally, running your installer with logging would also tell you why a custom action was not performed.
So the exact settings you use and the version of PowerShell Studio used as well as OS information would all be helpful to diagnose the issue.
Additionally, running your installer with logging would also tell you why a custom action was not performed.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: include files inside of .EXE or .MSI
Product: PowerShell Studio 2018 (64 Bit)
Build: v5.5.155
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.17763.0
Target machines are all Windows 10 - 1709. Local PowerShell version on each Windows 10 workstation is 5.1
Within the Script of my Form do I need to call the .EXE I want to run? i.e.
$form1_Load={
& .\MyCustom.exe}
Build: v5.5.155
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.17763.0
Target machines are all Windows 10 - 1709. Local PowerShell version on each Windows 10 workstation is 5.1
Within the Script of my Form do I need to call the .EXE I want to run? i.e.
$form1_Load={
& .\MyCustom.exe}
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: include files inside of .EXE or .MSI
That really depends on when you want it to run. By using a custom action it seemed you want to run it on install.
If you run it from the load event it launches obviously each time your app is started.
I cannot tell from your post what you are actually trying to do. Each way serves a purpose of course, but I cannot tell which one would be best for you.
If you run it from the load event it launches obviously each time your app is started.
I cannot tell from your post what you are actually trying to do. Each way serves a purpose of course, but I cannot tell which one would be best for you.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: include files inside of .EXE or .MSI
on the custom actions I have 4 different ways to run it.
Immediately
When the system is being modified (deferred)
During installation rollback
After the system as been successfully modified (commit)
How do you run it on the Load Event? Do you mean when the Form Loads?
$form1_Load={
& .\MyCustom.exe}
This is what I already asked.
Immediately
When the system is being modified (deferred)
During installation rollback
After the system as been successfully modified (commit)
How do you run it on the Load Event? Do you mean when the Form Loads?
$form1_Load={
& .\MyCustom.exe}
This is what I already asked.
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: include files inside of .EXE or .MSI
I would refer you to this article for more information on custom actions: https://www.sapien.com/blog/2018/02/26/ ... i-builder/
If you are trying to run a file that is part of your MSI, 'Immediately' won't work, since that is done before files are copied.
Generally 'commit' is the safest bet unless you have a good reason for any other time.
As for executing your custom exe from the event handler, using ./ is almost always a bad idea. There is no guarantee that the current folder is the same as where your application resides.
It can be anything and if you have shortcuts on a desktop, the user can also set it to something else easily.
I would recommend to always use the full path and obtaining the path to the hosting script or exe using the Get-ScriptDirectory snippet.
I would also use this code
to determine if the program was executed correctly.
If you are trying to run a file that is part of your MSI, 'Immediately' won't work, since that is done before files are copied.
Generally 'commit' is the safest bet unless you have a good reason for any other time.
As for executing your custom exe from the event handler, using ./ is almost always a bad idea. There is no guarantee that the current folder is the same as where your application resides.
It can be anything and if you have shortcuts on a desktop, the user can also set it to something else easily.
I would recommend to always use the full path and obtaining the path to the hosting script or exe using the Get-ScriptDirectory snippet.
I would also use this code
- if($LASTEXITCODE -eq 0)
- {
- Write-Host "The last PS command executed successfully"
- }
- else
- {
- Write-Host "The last PS command failed"
- }
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: include files inside of .EXE or .MSI
Yes, I had found that same web page. I now have this working (almost) I can make it run my .EXE when I install the .MSI which is very cool but only if the .EXE is already on the machine. It has to be in c:\temp\ for the .MSI to see it. I tried to add the file within the .MSI but it never gets copied down to the c:\temp.
files / folder - Files (drag and drop files here)
c:\temp\desktop_manager.exe
Custom Action - Properties
file = c:\temp\desktop_manager.exe
Folder = INSTALLDIR
execution time = after the system has been successfully modified (commit)
execution options = none
when I compile this shouldn't it compile the c:\temp\desktop_manager.exe within the .MSI file?
files / folder - Files (drag and drop files here)
c:\temp\desktop_manager.exe
Custom Action - Properties
file = c:\temp\desktop_manager.exe
Folder = INSTALLDIR
execution time = after the system has been successfully modified (commit)
execution options = none
when I compile this shouldn't it compile the c:\temp\desktop_manager.exe within the .MSI file?
- Alexander Riedel
- Posts: 8488
- Last visit: Tue Apr 16, 2024 8:42 am
- Been upvoted: 37 times
Re: include files inside of .EXE or .MSI
Please do not use the term 'compile'. It just creates confusion. You package a script to make an exe (that is also not a compiler). Or you build/create/make an MSI.
The term "to compile" in this context means to translate source code into binary machine instructions or at least ILASM (Intermediate Language ASeMbly), both of which do not apply here.
"when I compile this shouldn't it compile the c:\temp\desktop_manager.exe within the .MSI file?"
The MSI builder will add any file to your installer that you specify. If you do not add it, no, it will not add it just because you call it somewhere.
If you add your file from C:\Temp\DesktopManager.exe it does not mean that the installer will copy it to that location. That is not how installers operate.
The files you add are collected from the location you specify, but will be copied on the target machine to the specified install folder.
So your 'C:\Temp\DesktopManager.exe' will end up in 'C:\Program Files\<your product>\DesktopManager.exe. Assuming your target folder is under "C:\Program Files".
This may help you as well:
https://www.sapien.com/blog/2024/01/17/ ... r-install/
The term "to compile" in this context means to translate source code into binary machine instructions or at least ILASM (Intermediate Language ASeMbly), both of which do not apply here.
"when I compile this shouldn't it compile the c:\temp\desktop_manager.exe within the .MSI file?"
The MSI builder will add any file to your installer that you specify. If you do not add it, no, it will not add it just because you call it somewhere.
If you add your file from C:\Temp\DesktopManager.exe it does not mean that the installer will copy it to that location. That is not how installers operate.
The files you add are collected from the location you specify, but will be copied on the target machine to the specified install folder.
So your 'C:\Temp\DesktopManager.exe' will end up in 'C:\Program Files\<your product>\DesktopManager.exe. Assuming your target folder is under "C:\Program Files".
This may help you as well:
https://www.sapien.com/blog/2024/01/17/ ... r-install/
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.