Jump to content

Recommended Posts

Posted

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.

Posted (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 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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...