scriptjunkie Posted July 9, 2009 Share Posted July 9, 2009 I am trying to run this command: $programlocation = "c:\program files\app\app.exe" $filetoprocess = "c:\program files\app\data.txt" $output = "c:\program files\app\output.txt" Run(@ComSpec & ' /k "' & $programlocation & '" options "' & $filetoprocess & '" > "'&$output&'"') I keep getting a error that 'c:\program' is not valid. If I copy the info to my clipboard and paste it to a oommand line, the command runs. clipput("' & $programlocation & '" options "' & $filetoprocess & '" > "'&$output&'"') I have to put quotes in my file directories because of spaces. However I can't seem to get multiple quotes to work correctly. If I use only 1 set of quotes it works. $programlocation = "c:\program files\app\app.exe" $filetoprocess = "c:\data.txt" $output = "c:\output.txt" Run(@ComSpec & ' /k "' & $programlocation & '" options ' & $filetoprocess & ' > '&$output) Maybe it's a limitation? Thanks for your time looking at my problem. Link to comment Share on other sites More sharing options...
archgriffin Posted July 9, 2009 Share Posted July 9, 2009 (edited) This is apparently due to the way cmd /c or /k handles quotes, see http://www.computerhope.com/cmd.htm for more information on that. To "fix" it, try the following: $programlocation = "c:\program files\app\app.exe" $filetoprocess = "c:\program files\app\data.txt" $output = "c:\program files\app\output.txt" Run(@ComSpec & ' /k ""' & $programlocation & '" options "' & $filetoprocess & '" > "'&$output&'""') Notice the double quoting, since the first and last characters are getting stripped, this would "preserve" them. So note, it is not a limitation of AutoIt, just the way cmd.exe works. Edited July 9, 2009 by archgriffin "Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend. Link to comment Share on other sites More sharing options...
scriptjunkie Posted July 15, 2009 Author Share Posted July 15, 2009 Great that worked... Thanks!!! Link to comment Share on other sites More sharing options...
herewasplato Posted July 15, 2009 Share Posted July 15, 2009 I know that you got it working, but do you really need @ComSpec to run the app? [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now