title: Command-line arguments to an exe
body: <p>I have a slight problem with Powershell strings. There is a Java program I'm using called <a href="http://symmetricds.codehaus.org" rel="nofollow noreferrer">SymmetricDS</a> which accepts arguments to a Windows batch file for certain administrative functions. One of these is to open registration for a node, passing a string containing the node's group and id:</p>
  
  <pre><code>&amp; .\bin\sym.bat -p symmetric.properties --open-registration 'store,01'
  </code></pre>
  
  <p>In the batch file, java is called, with properties I passed above being passed in like so:</p>
  
  <pre><code>java -Dthis -Dthat -Dfoo -Dbar %1 %2 %3 %4 %5 %6 %7 %8 %9
  </code></pre>
  
  <p>The function in the java itself fails after this part:</p>
  
  <pre><code>int index = argument.trim().indexOf(",");
  if (index &lt; 0) {
      throw new SymmetricException("LauncherMissingFilenameTriggerSQL", OPTION_OPEN_REGISTRATION);
  }
  </code></pre>
  
  <p><code>index</code> apparently is -1. Why it is not finding the comma character, I don't know. I just know that when I run the same in a .cmd or .bat file, it works just fine:</p>
  
  <pre><code>.\bin\sym.bat -p symmetric.properties --open-registration "store,01"
  </code></pre>
  
  <p>I suspect it has something to do with Powershell's string being Unicode, and something improper happens in their journey from there into a batch file and then into java.</p>
  
  <p>Anybody know how I can call this directly in Powershell?</p>
  
  <p><strong>Resolved</strong>: <a href="https://stackoverflow.com/questions/4430131/command-line-arguments-to-an-exe/4434900#4434900">zdan's answer</a> works, as does tricking Powershell a little bit like this:</p>
  
  <pre><code>.\bin\sym.bat -p symmetric.properties --open-registration '"store,01"'
  </code></pre>