I have an application that has not Exit button but just the window UI "X" (hard to believe) and Im trying to close this application gracefully from a button the application provides by the use of Shell, this button has two fields to run a Shell; Command and Command Arguments.
I'm trying to run a PowerShell that when I run it on the PowerShell window work fine;
PS C:\Users\MyProfile\Desktop:> Get-Process MyApplication | Foreach-object { $_.CloseMainwindow() | Out-Null }
It closes the application and it ask if I need to save any changes when appropriate when run from Powershell console.
How can I run this Powershell from the button the application provides?
Can it be run from with in the same application I'm trying to close?
I try to save the file with a .PS1 extension and call it from the Shell button but can not make it work, what is the syntax to do this or how can I run the Powershell line from the button?