Page 1 of 2

BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Mon Mar 09, 2020 9:40 am
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 26378 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?

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Mon Mar 09, 2020 9:52 am
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.

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Mon Mar 09, 2020 1:03 pm
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

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Tue Mar 10, 2020 5:39 am
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

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Tue Mar 10, 2020 6:47 am
by Alexander Riedel
Does not display any such message.
preparetest.png
preparetest.png (8.39 KiB) Viewed 26314 times
preparetest cmd.png
preparetest cmd.png (10.78 KiB) Viewed 26314 times

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Tue Mar 10, 2020 8:58 am
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.

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Tue Mar 10, 2020 9:10 am
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.

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Tue Mar 10, 2020 10:11 am
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.

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Tue Mar 10, 2020 11:26 am
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.

Re: BUG BUILDING EXE WITH SCRIPT ENGINE POWERSHELL 5

Posted: Wed Mar 11, 2020 5:05 am
by ramses147
I send you the screenshots and the executable so you can understand better.