{"id":4721,"date":"2014-03-30T14:58:57","date_gmt":"2014-03-30T14:58:57","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/passing-a-string-to-the-windows-command-line-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:58:57","modified_gmt":"2014-03-30T14:58:57","slug":"passing-a-string-to-the-windows-command-line-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/passing-a-string-to-the-windows-command-line-collection-of-common-programming-errors\/","title":{"rendered":"Passing a string to the Windows command line-Collection of common programming errors"},"content":{"rendered":"<p>As I said in my comment &#8211; &#8216;They are executed as separate commands, they are not related just because you executed one before the other&#8217;<\/p>\n<p>From the <code>Runtime.exec( string )<\/code> javadoc &#8211;<\/p>\n<blockquote>\n<p>Executes the specified command and arguments in a separate process.<\/p>\n<\/blockquote>\n<p>You need to chain the commands together to get <code>cmd<\/code> to process your command, I believe you need to use the <code>\\k<\/code> flag to specify what commands you need executed on the command line.<\/p>\n<pre><code>Runtime rt = Runtime.getRuntime();  \nString start = \"cmd \/k \";\nString cmd = \"LogParser;\\n\" Select top 10 * into c:\\temp\\test9.csv from application\";\nrt.exec(start + cmd);\n<\/code><\/pre>\n<p>Not tested as I don&#8217;t have windows, but it should be similar to this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I said in my comment &#8211; &#8216;They are executed as separate commands, they are not related just because you executed one before the other&#8217; From the Runtime.exec( string ) javadoc &#8211; Executes the specified command and arguments in a separate process. You need to chain the commands together to get cmd to process your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4721","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4721","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4721"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4721\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}