BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

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.
User avatar
ramses147
Posts: 110
Joined: Fri Sep 16, 2016 4:27 am

BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by ramses147 »

I have version 5.6.162, every time I build a ps1 file in exe, by configuring Script Engines "Powershell 5", when I start the executable, on each line of write-host there is always the following writing:
Script Packager - AD Users Permissions Report - TT Informatica.ps1003991.png
Script Packager - AD Users Permissions Report - TT Informatica.ps1003991.png (35.08 KiB) Viewed 22150 times
Preparing modules for first use.
Preparing modules for first use.
Preparing modules for first use.

can you please tell me how you can eliminate this bug?

User avatar
mxtrinidad
Posts: 399
Joined: Sun Mar 03, 2013 12:42 pm

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by mxtrinidad »

Can you please provide a sample script of what you considered is a bug? I will help understand the issue you're experiencing.

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

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by Alexander Riedel »

The message 'Preparing modules for first use.' is a Powershell message that stems from auto-loading custom modules.
Examine your script for modules used and load them explicitly on startup. That usually helps the problem.
Please understand that this is powershell output and has nothing to do with the packager.
A quick Google search shows a similar issue here: https://stackoverflow.com/questions/447 ... sage-stuck
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ramses147
Posts: 110
Joined: Fri Sep 16, 2016 4:27 am

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by ramses147 »

This a sample, but in more complex script "Preparing modules for first use." appear frequently during script execution.

try build this simple code with ps5 engine configuration

---------------------------

cls

$startdate = (Get-Date 06/02/2020)
$enddate = (Get-Date 06/02/2021)
$avviso = '15'

$notifydate = (Get-Date $enddate).AddDays(- $avviso)
$today = (Get-Date)
$enddateformat = ($enddate).ToString('dd/MM/yyyy')

IF ($today -ge $startdate -and $today -le $enddate) {
Write-Host -ForegroundColor Green "Run script"
}

Start-Sleep 3

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

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by Alexander Riedel »

Does not display any such message.
preparetest.png
preparetest.png (8.39 KiB) Viewed 22086 times
preparetest cmd.png
preparetest cmd.png (10.78 KiB) Viewed 22086 times
Attachments
preparetest.exe.zip
(156.62 KiB) Downloaded 36 times
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ramses147
Posts: 110
Joined: Fri Sep 16, 2016 4:27 am

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by ramses147 »

Your tests are not going well.
I talked about compiling the script in EXE format and running it, that's the problem.
If you use my same version of PS studio you will see that the problem occurs.

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

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by Alexander Riedel »

What do you mean my tests are not going well? It's not a compiler. It just runs powershell in a host on your machine.
I packaged with the same packager you use and the code you provided.
Run the exe I packaged here on YOUR machine and see what it does.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ramses147
Posts: 110
Joined: Fri Sep 16, 2016 4:27 am

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by ramses147 »

Look at my first post, you have to publish with that specific configuration otherwise you will never see that error.
Provided that you have my same version ..
I can not send exe files here in the forum so you have to test it, what you did is not good.

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

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by Alexander Riedel »

Ok, I am gonna break this to you as gentle as I can.
I wrote the packager code and the code for the hosts, so chances are, I do know a little bit more about it than you. So instead of telling me that what I do is no good, how about you follow my lead here.
I packaged your code with a Windows host and a command line host, the latter being what you have shown in your screenshot. That is what you see in the screenshots I posted that you just dismissed as “no good”. The engine selection is all you have shown, so I cannot possible use your exact configuration because you have not provided that. If you did anything special there you should provide that.
Additionally, I have attached a zip file with a packaged exe to my response with the screenshots. I can see you have not downloaded it yet, so you should maybe do that.
I also asked you to run that on your machine to see what it does.
That is to determine if the packaging is at fault or your local configuration.
Your turn.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
ramses147
Posts: 110
Joined: Fri Sep 16, 2016 4:27 am

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Post by ramses147 »

I send you the screenshots and the executable so you can understand better.
Attachments
test 2.zip
(49.8 KiB) Downloaded 35 times