Question on Creating .EXE from current script.

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.
slybry70
Posts: 4
Last visit: Thu Oct 07, 2021 1:14 pm

Question on Creating .EXE from current script.

Post by slybry70 »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: Powershell Studio 2021
Operating system:Windows 10
PowerShell version(s): 5

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

DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

I am very new to PS Studio and also to powershell... My first question is about create a .exe from my scripts that I am working on. Currently I have a simple script that I am trying to convert to an .exe after I finished it.

I went to this site on your blog to go through and see if I could figure it out but each of the options to convert it to a .exe would create a .config file that is an XML configuration file also and the .exe would not work without it. I was assuming if it converts to a .exe that there would be no need for other files for the .exe to work....

I tried the V5 host (Windows Application) and just the Windows option and both created the .xml config file and the .exe would not work standalone without it.

Is there a way to convert the .ps1 to a .exe with just the output being a standalone .exe file?

Thank you.

User avatar
brittneyr
Site Admin
Posts: 917
Last visit: Wed Dec 01, 2021 9:27 am
Answers: 21
Been upvoted: 17 times

Re: Question on Creating .EXE from current script.

Post by brittneyr »

If you do not want a .config file to be generated, it can be turned off in the SAPIEN Script Packager Output Settings tab under Packager options:
Packager_GenerateConfigFile.png
Packager_GenerateConfigFile.png (60.88 KiB) Viewed 5260 times
Brittney Ryn
SAPIEN Technologies, Inc.

User avatar
Alexander Riedel
Posts: 7810
Last visit: Wed Dec 01, 2021 10:35 am
Answers: 6
Been upvoted: 12 times

Re: Question on Creating .EXE from current script.

Post by Alexander Riedel »

.NET applications generally require the config file. PowerShell is .NET based. That is how Microsoft designed that. We would not generate that file unless it is necessary.
You can read more about it here: https://docs.microsoft.com/en-us/dotnet ... gure-apps/
Why does that file bother you?
If you move to PowerShell 7 and .NET Core, a packaged application is a good number of files in a folder. That is just how it is.
Alexander Riedel
SAPIEN Technologies, Inc.

slybry70
Posts: 4
Last visit: Thu Oct 07, 2021 1:14 pm

Re: Question on Creating .EXE from current script.

Post by slybry70 »

When coding in PowerShell and other formats I am just used to working with a single file. Since all of the PowerShell scripts I have made so far have not required any other external files other then the .ps1 but the .exe I am finding now is different. Like I said I am new to PowerShell and still learning.

So if the .xml is not included and ran with the .exe after conversion it will not work with full functionality since it will break some of the .net functionality?

One more thing that was interesting was when I ran the .exe it also open the .config file. If I run a .exe file I would not want the config file to open in addition every time as the .exe runs.

slybry70
Posts: 4
Last visit: Thu Oct 07, 2021 1:14 pm

Re: Question on Creating .EXE from current script.

Post by slybry70 »

Sorry. It doesn't open the .xml file it seems when I click on the .exe but it opens another window in addition to running the code with the same name as the .exe and its empty of information but has the File|EDIT|HELP at top.
Attachments
Screenshot 2021-10-07 082430.png
Screenshot 2021-10-07 082430.png (14.13 KiB) Viewed 5139 times

User avatar
Alexander Riedel
Posts: 7810
Last visit: Wed Dec 01, 2021 10:35 am
Answers: 6
Been upvoted: 12 times

Re: Question on Creating .EXE from current script.

Post by Alexander Riedel »

It does not open the config file in that manner. The .config file is usually required and should not be tampered with.
Alexander Riedel
SAPIEN Technologies, Inc.

slybry70
Posts: 4
Last visit: Thu Oct 07, 2021 1:14 pm

Re: Question on Creating .EXE from current script.

Post by slybry70 »

Do you know why when I run the .exe its generating the other window in addition to the script? Script runs fine without displaying any other windows when in ps1 format. Run the .exe in any way and it generates the other window.

User avatar
Alexander Riedel
Posts: 7810
Last visit: Wed Dec 01, 2021 10:35 am
Answers: 6
Been upvoted: 12 times

Re: Question on Creating .EXE from current script.

Post by Alexander Riedel »

From the information posted I cannot determine how you packaged your script exactly or what it is doing internally.
Most likely you are packaging a Form script using a Windows Application engine and not a Windows Forms engine. The preview window when selecting a packaging engine provides pertinent information.
2021-10-07_8-58-26.png
2021-10-07_8-58-26.png (84.42 KiB) Viewed 5125 times
Alexander Riedel
SAPIEN Technologies, Inc.