title: start-process with a special name, or handle to kill it
body: <p>We have a number of node.js programes that all are created with powershell. We used the start-process to spawn the node.js executable in the background (node.exe).</p>
  
  <p>We would like to give each one a different "handle" so that we can later use the powershell command stop-process to kill them. e.g. start-process -Name 'wServer'
  The powershell script to kill, will be different than the one to start, and a different user might well use it.</p>
  
  <p>I am stuck on how to identify each node.exe different. It is not the executable that is different but the path to the app.js</p>
  
  <p>Here is how we start one of them:</p>
  
  <pre><code>$reg = Get-Item -Path "hklm:\SOFTWARE\us\EGPL\GeoLibrarian" 
  $path = $reg.GetValue('LibrarianPath').ToString() 
  $sixtyfour = [Environment]::Is64BitProcess
  
  # Now start running Watson
  $node = "C:\Program Files\nodejs\node.exe" 
  $arg = "app.js"
  $dir = "$path\Watson"
  start-process -WorkingDirectory $dir $node $arg
  Write-Host "64-Bit Powershell: "$sixtyfour
  Write-Host "PowerShell Version: "$PSVersionTable.PSVersion
  Write-Host "Watson running in background"
  </code></pre>
  
  <p>right now, I can kill ones started with a unique window via this sequence, I don't think the ones started in powershell will have a window.</p>
  
  <pre><code>Write-Host "Kill watson task"
  $watson = get-process | where-object {$_.MainWindowTitle -eq 'WatsonJS'}
  Stop-Process -Id $watson.Id -ErrorAction SilentlyContinue
  </code></pre>