Page 1 of 1

Packaging PowerShell script with supporting files as an EXE

Posted: Mon Nov 12, 2018 3:45 pm
by robmo
Product, version and build: PrimalScript 2018 build 7.4.118.0
32 or 64 bit version of product: 64-bit
Operating system: Windows 10 1803 Enterprise
32 or 64 bit OS: 64-bit

*** Please add details and screenshots as needed below. ***

Hi,

Is it possible to package a PowerShell script that requires supporting files, such as files to install an application, into one executable that includes all files? If so, would you point me to some articles that describe how this is done?

Thank you!
Rob

Re: Packaging PowerShell script with supporting files as an EXE

Posted: Mon Nov 12, 2018 4:13 pm
by Alexander Riedel
I am not sure what you want to accomplish from the description.
Do you want to install something and run a script as part of that installation?
Or install an app that will include other applications/installers?

Generally speaking, you would create an MSI for your script or packaged executable along with any required auxiliary files.
Then, if needed you would use custom actions in that MSI to execute any additional steps during installation as needed.
All this can be done in PrimalScript, yes.
This might help: https://info.sapien.com/index.php/packaging-deployment

Re: Packaging PowerShell script with supporting files as an EXE

Posted: Tue Nov 13, 2018 7:21 am
by robmo
I have a couple of examples. One package includes a PS1 and XML file for customizing the Windows 10 start menu. Another example is using a PowerShell script to automate the installation of UltraVNC. The VNC payload is 6 files.

Are there any instructions that explain how to package multiple files into an MSI? I suspect I need a custom manifest as well which looks like an XML file is expected. Is there a tool or instructions describing how to package a group of files as an MSI or how to create the manifest XML? The link you provided does not explain how to package an MSI.

Thank you!

Rob

Re: Packaging PowerShell script with supporting files as an EXE

Posted: Tue Nov 13, 2018 8:49 am
by robmo
I tried using Deploy > Installer > Settings to configure an MSI package with a PS script, XML and a shortcut. It build without any errors. When I run it on a test client, I can clearly see that the MSI is running but when I inspect the file system, no changes were made at all and no errors were thrown. How do I get an MSI package to run the PowerShell script when it is executed? The script doesn't seem to be executed and I'm not entirely sure what just happened. I will try MSI logging to see if that reveals any answers.

I tried adding a Custom Action pointing to the PS script in the source folder and it seemed to execute with no errors but no changes were made to the file system again. I also noticed that it registered this package in Programs and Features. Is there some way to prevent the script from being registered in Control Panel? This script copies an XML and a shortcut to two different folders in the file system. Users should not be offered a way to 'rollback'. If I run the script manually, it copies the files into the file system and nothing is registered in Control Panel. I would like the same result with a packaged MSI, if that is possible.

Re: Packaging PowerShell script with supporting files as an EXE

Posted: Fri Nov 16, 2018 7:19 am
by robmo
Any ideas?

Re: Packaging PowerShell script with supporting files as an EXE

Posted: Mon Nov 19, 2018 6:14 am
by Alexander Riedel
Actually one of the articles (https://info.sapien.com/index.php/packaging-deployment/from-script-to-server-deploying-solutions-with-primalscript) provides instructions on creating an MSI.
Here is a blog article on custom actions: https://www.sapien.com/blog/2018/02/26/custom-actions-in-primalscript-2018s-msi-builder/
If you are executing an MSI file, the only way to know if there where any errors is to execute it with logging.
You can do that from within PrimalScript from the Install drop down in the Deploy tab or you can run it manually.
https://docs.microsoft.com/en-us/windows/desktop/msi/command-line-options
I am not aware how you can prevent an MSI from not registering your installation. It seems counter-productive from a security perspective. But I will look into it.