Compiled Powershell-Script did not terminate

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 1 year and 9 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
Tochtermann
Posts: 3
Last visit: Fri Mar 17, 2023 12:56 am
Has voted: 1 time

Compiled Powershell-Script did not terminate

Post by Tochtermann »

We compiled a Powershell Script with the Setting "SAPIEN PowerShell V5 Host (Windows Application)" for Target "Microsoft Windows 64bit"
The Script is running good, but the Process is still running. Even if I use "Exit 0" as last Command.
Attachments
CoopPrinterAdd.ps1
Code
(15.86 KiB) Downloaded 52 times
by brittneyr » Tue May 31, 2022 6:46 am
Exit will basically terminate the PowerShell script, but it does not destroy the Window or send a close event to it, so the window will remain there unless its a command line application.

If this was a form, you can simply close the forum object. For example, $Form1.Close() where $Form1 is the name of your form variable.

If you need to make an emergency stop, this needs to be done:

Code: Select all

$process = Get-Process -id $pid
$null = $process.Kill()
Go to full post
User avatar
brittneyr
Site Admin
Posts: 1654
Last visit: Wed Mar 27, 2024 1:54 pm
Answers: 39
Been upvoted: 30 times

Re: Compiled Powershell-Script did not terminate

Post by brittneyr »

Exit will basically terminate the PowerShell script, but it does not destroy the Window or send a close event to it, so the window will remain there unless its a command line application.

If this was a form, you can simply close the forum object. For example, $Form1.Close() where $Form1 is the name of your form variable.

If you need to make an emergency stop, this needs to be done:
  1. $process = Get-Process -id $pid
  2. $null = $process.Kill()
Brittney
SAPIEN Technologies, Inc.
Tochtermann
Posts: 3
Last visit: Fri Mar 17, 2023 12:56 am
Has voted: 1 time

Re: Compiled Powershell-Script did not terminate

Post by Tochtermann »

Thank You this did the trick. I have to remove the "Exit 0" and replaced it with the code provided.
This Problem is solved.
This topic is 1 year and 9 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