PS Studio .EXE exits while script is still running in the background

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
Coronaj1
Posts: 4
Last visit: Mon Aug 02, 2021 8:40 am

PS Studio .EXE exits while script is still running in the background

Post by Coronaj1 »

When I package a .ps1 into a silent .exe, launching the .exe from a command prompt the .exe exits immediately while the script is still running in the background. Not sure if this is by design or if I supposed to configure the .exe differently. Is there anyway to keep the .exe running until the script finishes?

This was tested with a simple script that creates some files and having a 20 second pause in the script. When you launch .exe in command prompt the .exe immediately exits but the script is still running.

jvierra
Posts: 14982
Last visit: Sun Nov 28, 2021 3:32 pm
Answers: 14
Has voted: 3 times
Been upvoted: 11 times

Re: PS Studio .EXE exits while script is still running in the background

Post by jvierra »

What is a "silent exe"?

Coronaj1
Posts: 4
Last visit: Mon Aug 02, 2021 8:40 am

Re: PS Studio .EXE exits while script is still running in the background

Post by Coronaj1 »

Packaging a .ps1 using the silent engine in powershell studio.

jvierra
Posts: 14982
Last visit: Sun Nov 28, 2021 3:32 pm
Answers: 14
Has voted: 3 times
Been upvoted: 11 times

Re: PS Studio .EXE exits while script is still running in the background

Post by jvierra »

The silent engine has no output. What is it you are looking to happen?

If you want the EXE to wait then don't use the silent engine.

See: https://www.sapien.com/blog/2019/07/24/ ... able-file/

Coronaj1
Posts: 4
Last visit: Mon Aug 02, 2021 8:40 am

Re: PS Studio .EXE exits while script is still running in the background

Post by Coronaj1 »

I agree that the silent engine has no output. When the .exe is launched via CMD I would like to keep the console busy while the script process is running. Anyway to accomplish this?

jvierra
Posts: 14982
Last visit: Sun Nov 28, 2021 3:32 pm
Answers: 14
Has voted: 3 times
Been upvoted: 11 times

Re: PS Studio .EXE exits while script is still running in the background

Post by jvierra »

Don't use the silent engine. Read the link I posted which will give you all of the options for the different engines and how to use them.

The point of a silent engine is that it has no console at all so there is no way to freeze the console.

Coronaj1
Posts: 4
Last visit: Mon Aug 02, 2021 8:40 am

Re: PS Studio .EXE exits while script is still running in the background

Post by Coronaj1 »

Okay so how can I get the EXE to wait without any output?

Locked