[PowerShell] - Graceful shutdown of a program
Solved
blux
Posted messages
5044
Registration date
Status
Moderator
Last intervention
-
Luc -
Luc -
Hello,
I'm looking to terminate a program normally (simulating a click on the Windows close button or File/Close/Quit from the menu) with PowerShell.
So far, I have only found stop-process. But the problem is that it performs a forceful kill of the process. Programs like Firefox don't always recover from this (message on restart regarding a possible crash).
That's why I'm looking for the method that will allow me to close it cleanly.
I also tried 'taskkill' in the command line, but it does the same kind of damage...
A command, even in vbscript, would make me happy...
Thanks in advance.
--
A+ blux
I'm looking to terminate a program normally (simulating a click on the Windows close button or File/Close/Quit from the menu) with PowerShell.
So far, I have only found stop-process. But the problem is that it performs a forceful kill of the process. Programs like Firefox don't always recover from this (message on restart regarding a possible crash).
That's why I'm looking for the method that will allow me to close it cleanly.
I also tried 'taskkill' in the command line, but it does the same kind of damage...
A command, even in vbscript, would make me happy...
Thanks in advance.
--
A+ blux
"Fools dare to do anything. That's how we recognize them"
3 answers
-
I found (long live Google in English):
get-process program_name | %{ $_.closemainwindow() }
In fact, we are asking to close the main window. It just took some thought!
--
A+ blux"The fools, they dare everything. It's even how you recognize them"
-
Hi :)
Yes, taskkill (like processclose in AutoIt) "kills" the process...
You basically want to simulate a left-click on the cross...
If I find that for you in AutoIt, would that be acceptable?
Because, I know how to simulate pressing alt+F4 in AutoIt: Is that not what you're looking for?
Otherwise, I don't know VBScript ;)
Anyway, good luck to you :)
++ -
Hello
I don't know if this can help you, but well, nothing ventured, nothing gained ;)
https://www.generation-nt.com/reponses/fermer-application-proprement-entraide-2484831.html
EDIT: Even in AutoIt, the fact of doing processclose, Firefox says crash ^^
Same in command prompt...
++