include files inside of .EXE or .MSI

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
Locked
User avatar
mqh777
Posts: 237
Joined: Tue Feb 25, 2014 1:01 pm

include files inside of .EXE or .MSI

Post by mqh777 » Mon Mar 04, 2019 12:08 pm

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?

User avatar
Alexander Riedel
Posts: 7098
Joined: Tue May 29, 2007 4:43 pm

Re: include files inside of .EXE or .MSI

Post by Alexander Riedel » Mon Mar 04, 2019 12:55 pm

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.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
mqh777
Posts: 237
Joined: Tue Feb 25, 2014 1:01 pm

Re: include files inside of .EXE or .MSI

Post by mqh777 » Mon Mar 04, 2019 1:45 pm

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}

User avatar
Alexander Riedel
Posts: 7098
Joined: Tue May 29, 2007 4:43 pm

Re: include files inside of .EXE or .MSI

Post by Alexander Riedel » Mon Mar 04, 2019 1:51 pm

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.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
mqh777
Posts: 237
Joined: Tue Feb 25, 2014 1:01 pm

Re: include files inside of .EXE or .MSI

Post by mqh777 » Mon Mar 04, 2019 2:42 pm

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.

User avatar
Alexander Riedel
Posts: 7098
Joined: Tue May 29, 2007 4:43 pm

Re: include files inside of .EXE or .MSI

Post by Alexander Riedel » Mon Mar 04, 2019 3:22 pm

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
  1. if($LASTEXITCODE -eq 0)
  2.  
  3. {
  4.  
  5.     Write-Host "The last PS command executed successfully"
  6.  
  7. }
  8.  
  9. else
  10.  
  11. {
  12.  
  13.     Write-Host "The last PS command failed"
  14.  
  15. }
to determine if the program was executed correctly.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
mqh777
Posts: 237
Joined: Tue Feb 25, 2014 1:01 pm

Re: include files inside of .EXE or .MSI

Post by mqh777 » Tue Mar 05, 2019 8:13 am

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?

Locked