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.
This topic is 2 years and 7 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.
Locked
Coronaj1
Posts: 4
Last visit: Thu Feb 01, 2024 9:58 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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: Thu Feb 01, 2024 9:58 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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: Thu Feb 01, 2024 9:58 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 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: Thu Feb 01, 2024 9:58 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?
This topic is 2 years and 7 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.
Locked