Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://stackoverflow.com/a/28482050/5079799


function Set-CloseIfRunning {
 param (
  $Process
 )
 $Process = Get-Process $Process -ErrorAction SilentlyContinue
  IF ($Process) {
   $Process.CloseMainWindow()
   Sleep 5
   IF (!$Process.HasExited) {
    $Process | Stop-Process -Force
   }
   IF (!$Process.HasExited) {
    tskill $Process
   }
  } 
}
Set-CloseIfRunning -Process WINWORD
  • No labels