title: Process gets hung up and unable to stop-process or terminate in Powershell
body: <p>I am new to Powershell and CMD scripting and hope you can help.  I am running code in R which includes using the shell command to run a batch file that opens and runs a process in another program, Quest Analytics. I notice that this kicks off a process in my Task Manager called "QuestConsole.exe."  Quest does some stuff then saves a file to my C drive and is supposed to close.  However, it does not always close and remains hung up with the memory usage showing no change.  R will not commence with the rest of my code until I actually force the process closed in Task Manager.  I have no problem closing it that way and R then picks up where it left off with no issues.  I am designing this to run autonomously through a shiny app so won't be able to use Task Manager to close it every time it gets hung up. So I decided to try building a Powershell script that runs continuously in the background and kills the QuestConsole.exe process if it has been active for more than 6 minutes.</p>
  
  <p>I've tried 2 different approaches in Powershell:</p>
  
  <pre><code>(Get-WmiObject win32_process -Filter “name = ‘QuestConsole.exe’”).Terminate()
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Stop-Process -Name QuestConsole
  </code></pre>
  
  <p>Neither of these work. There is no error.  Powershell acts like everything is fine but the QuestConsole.exe process is still in Task Manager (mocking me!).</p>
  
  <p>I was able to get this to work in CMD:</p>
  
  <pre><code>Wmic process where name=”QuestConsole.exe” call terminate
  </code></pre>
  
  <p>I prefer to use Powershell because I have already written my script and the learning process was painful. Does anyone know any other ways to kill my process in PowerShell?  Perhaps an equivalent to the command that I used in CMD?  Also, I will include my Powershell script in case a kind soul can help me re-write it in CMD.  </p>
  
  <pre><code>While ($True) {
  $startTimeLimit = (Get-Date) - (New-TimeSpan -minutes 6)
  $questStart = (Get-Process QuestConsole).StartTime
  $eval = $questStart -gt $startTimeLimit
  if ($eval -eq $false)
  {
      Stop-Process -Name QuestConsole
  }
  }
  </code></pre>