Packaging PowerShell script with supporting files as an EXE

Support for all customers who have purchased a PrimalScript product license. This forum does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
robmo
Posts: 12
Joined: Wed Dec 14, 2011 11:03 am

Packaging PowerShell script with supporting files as an EXE

Post by robmo » Mon Nov 12, 2018 4:45 pm

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

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

Re: Packaging PowerShell script with supporting files as an EXE

Post by Alexander Riedel » Mon Nov 12, 2018 5:13 pm

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

User avatar
robmo
Posts: 12
Joined: Wed Dec 14, 2011 11:03 am

Re: Packaging PowerShell script with supporting files as an EXE

Post by robmo » Tue Nov 13, 2018 8:21 am

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

User avatar
robmo
Posts: 12
Joined: Wed Dec 14, 2011 11:03 am

Re: Packaging PowerShell script with supporting files as an EXE

Post by robmo » Tue Nov 13, 2018 9:49 am

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.

User avatar
robmo
Posts: 12
Joined: Wed Dec 14, 2011 11:03 am

Re: Packaging PowerShell script with supporting files as an EXE

Post by robmo » Fri Nov 16, 2018 8:19 am

Any ideas?

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

Re: Packaging PowerShell script with supporting files as an EXE

Post by Alexander Riedel » Mon Nov 19, 2018 7:14 am

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