pack dependencies in same .exe as script

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
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.
This topic is 1 year and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
kjrwbvomqchtlmknnx
Posts: 3
Last visit: Sat Dec 31, 2022 5:38 pm

pack dependencies in same .exe as script

Post by kjrwbvomqchtlmknnx »

Hi

I usually use ps2exe to redistribute my scripts. I recently learned about PowerShell studio and that is has the ability to "Convert scripts into executable (.exe) files."

I would like to ask if this feature allow to package dependencies as well in the executable to generate one single .exe file?

Example

my script.ps1 imports fileX.dll and fileY.dll.

With ps2exe I distribute 3 files, the converted script + the 2 DLL files. With PowerShell studio would it be possible to pack the .dll inside the same .exe as the script and share 1 single file?

Thanks
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: pack dependencies in same .exe as script

Post by Alexander Riedel »

Ah the ever elusive single executable thing.
No we do not and we don't plan on doing that. There are a a couple of reasons. I will re-iterate them here for everyone's reference.

1. There are an endless number of zip to exe packagers out there that do exactly that. They have largely fallen out of favor though. See the following points.
2. An executable that makes other executable files (i.e. DLLs) appear out of thin air looks like malware. Many a security software will not take kindly to that.
3. If it is distribution you are worried about, so you only have to create and distribute a single file, use an MSI (PowerShell Studio can generate one).
That is the industry standard and makes the software, version, publisher etc. visible.
It also verifies integrity of the files installed, deals with running processes and creates a defined set of files.
You can also use NuGet packages, which are really just glorified zip files with a defined structure.
4. Applications should always be placed (by whatever means) in a protected folder, e.g. underneath C:\Program Files.
That way no other application (or user) can just willy-nilly modify an application.
It takes admin privileges to modify files there, which makes it more secure and also implies that a self-extracting exe (built with whatever mechanism) will not work at all.
5. Applications in general, through growing complexity and through the use of more advanced .NET frameworks consist of an ever growing number of files. DLLs, dependency definition files (usually json), config files, data files, resources, images, you name it. So unpacking all this at application launch will become slower and more problematic as time goes by.

I am almost certain you don't agree with some or all of these points :-). I do not know your use case so you may have a particular reason for this self-extraction thing.
If you can elaborate, maybe I (or someone else) can point out what other options are available.
Alexander Riedel
SAPIEN Technologies, Inc.
kjrwbvomqchtlmknnx
Posts: 3
Last visit: Sat Dec 31, 2022 5:38 pm

Re: pack dependencies in same .exe as script

Post by kjrwbvomqchtlmknnx »

Hi

Thanks for your detailed reply! Appreciate it!

My use case is nothing fancy.

What I have is a restricted windows server environment, with no admin privileges for users. I am trying to keep the application fully portable and easy to copy from one instance to another.

The only problem is, when I pack everything as .zip/.7z and clearly state "please extract the entire archive using the extract to <folder name>" people still selectively pick the .exe file and extract it on its own, without the DLL files :shock: and complain about the app not working.

Packing as a .msi that extracts to some local user folder instead of C://... might be an option, but then people need to understand where that folder is so they can move it/copy it when needed

> I am almost certain you don't agree with some or all of these points
Not really. It is not a matter of agreeing/disagreeing, just a matter of being stuck with an annoying use-case :cry:

Still, thanks for your reply and happy new year!
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: pack dependencies in same .exe as script

Post by Alexander Riedel »

https://www.winzip.com/en/product/self-extractor/
Back in the day I used this on occasion. Maybe it works for you.
Alexander Riedel
SAPIEN Technologies, Inc.
kjrwbvomqchtlmknnx
Posts: 3
Last visit: Sat Dec 31, 2022 5:38 pm

Re: pack dependencies in same .exe as script

Post by kjrwbvomqchtlmknnx »

Totally forgot about those!

haven't seen one in the last 5-6 years

Thanks for the hint, I think It might work for me, I will give it a shoot!
This topic is 1 year and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.