title: Execute batch file with spaces in path
body: <p>I have problems to execute a batch file on a remote server via PowerShell. The user can choose several opinions in a pop-up window like <em>Servername</em>, <em>starting</em> or <em>killing</em> process and <em>Servicename</em>. The chosen items will be saved in variables.</p>
  
  <p>If all items are chosen, I want to merge the strings to one string and execute the batch script which is named like this result string.
  I try to do it as described in <a href="https://stackoverflow.com/questions/11846087/powershell-cmd-exe-and-spaces-in-path/33215731#33215731">this post</a>, but the batch script won't be executed.</p>
  
  <p>Example: </p>
  
  <pre><code>[String]$scriptpath="C:\tmp\"
  [String]$Servername = "xx040"
  [String]$actionprefix = "kill_process"
  [String]$action = $($actionprefix) + "-"
  [String]$Servicename = "service1"
  [String]$ServiceFullname = $($action) + $($Servicename) + ".bat"
  $batchPath = $("`"$scriptpath + $ServiceFullname `"")
  Invoke-Command -ComputerName $Servername -ScriptBlock {
    cmd.exe /c "`"$batchPath`""
  }
  </code></pre>