How to script clicking on "X" to close window

rated by 0 users

This post has
2
Replies |
2
Followers

I'm a newbie to Powershell. I'm trying to write a script that will close
some applications running on a server gracefully. The apps are running in CMD
windows and the correct procedure to close them is to just click on the "X" in
the upper right hand corner. I assumed that the Alt+F4 keystroke combination
would approximate that, but that doesn't work. Any suggestions would be much
appreciated. My code is: