Exe running several times in background, even when closed

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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 5 years and 10 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
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Exe running several times in background, even when closed

Post by stevens »

Hi,

Quick question, if I run my Powershell Studio Project exe and close it, I can see in processes that it is still running.
Can't alt + tab to it, but the process(es) is(are) still here.

Something I can do about this?
Please advise.
S.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Exe running several times in background, even when closed

Post by jvierra »

Have you tried fixing your code. A form can hide and still not close which might prevent the EXE from exiting.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Exe running several times in background, even when closed

Post by Alexander Riedel »

.Net processes can take a few seconds to close down. It is is longer than that you leave resources open. Make sure you exit loops, close jobs, close files and close forms.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Exe running several times in background, even when closed

Post by stevens »

Thanks Alexander, strange thing is that it is only on Windows 2016, not on Windows 2012 server.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Exe running several times in background, even when closed

Post by Alexander Riedel »

I don't know your code, so its not possible to tell :D
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Exe running several times in background, even when closed

Post by stevens »

There is nothing special to it, I close the project with the x of the form. It closes correctly on Windows 2012, not on 2016.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Exe running several times in background, even when closed

Post by Alexander Riedel »

Probably loading a different version of a module and the newer version is not terminating unless you kick it out with Remove-Module
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Exe running several times in background, even when closed

Post by Alexander Riedel »

Are you using PSUtils?
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Exe running several times in background, even when closed

Post by jvierra »

Windows 2010 and later do not necessarily remove a process from memory. Since W10 processes can remain dormant in memory even after they are close. All "Store" apps will stay in memory after they are closed. Non-store apps can also stay in memory.

I have not yet been able to track down the rules that govern this. Edge will remain in memory always after first execution. IE will stay in memory if certain COM objects have been activated. It is not clear if this is intended or some side-effect of the COM objects being used.

If you are using Excel or other Office apps via COM then this can cause your app to remain in memory.

This behavior is new to W10 and later systems.

There may be other causes of this behavior.
User avatar
stevens
Posts: 493
Last visit: Mon Sep 19, 2022 12:23 am
Has voted: 2 times

Re: Exe running several times in background, even when closed

Post by stevens »

Thanks for the update. That could explain things.

Note not related to this question: why are my other posts "locked" again -had this in the past also-?
Wanted to update my post on jobargs (can't open the example you posted, get message "Test-JobArgs.psf: Unable to load Test-JobArgs.psf (File Format: v3.1), because it was created with a different version of SAPIEN PowerShell Studio 2017") ... but it is locked.
This topic is 5 years and 10 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