Jump to content

Recommended Posts

Posted

I have a rather simple question. Say for I want to use the rundos command, yet in the command itself it requires quotations:

_RunDos("FOR /F "eol=; tokens=1 delims=, " %%i in (%name%) do echo %%i:%port%>>"converted.txt"")

Thats what it comes to look like in the Editor. Looks like to me it wouldn't work, but is there a way to make it work?

Posted

This has to work:

_RunDos('FOR /F "eol=; tokens=1 delims=, " %%i in (%name%) do echo %%i:%port%>>"converted.txt"')

Looks like it took you quite a while to post that. <_<

Posted

as the help file states, autoit supports using either single or double quotes to delimit strings.

In addition, the use of StringFormat() and other functions can greatly reduce the complexity required to properly render things such as the example above.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

  • 2 weeks later...
Posted

I am having problems trying to get a command to run when using the _RunDOS command. It works fine when using RunWait, but fails with _RunDOS. Here is an example of some testing I've done and the results (in the comments):

#include <process.au3>

$cmd = @ProgramFilesDir & "\mypath\myprog.exe"

RunWait($cmd) ; successful

_RunDOS($cmd) ; fails

$cmd2 = """" & @ProgramFilesDir & "\mypath\myprog.exe"""

RunWait($cmd2) ; successful

_RunDOS($cmd2) ; successful

$cmd3 = """" & @ProgramFilesDir & "\mypath\postie.exe"" -host:smtpserver -to:toemail -from:fromemail -s:""Testing"" -msg:""Test"" -v:9"

RunWait($cmd3) ; successful

_RunDOS($cmd3) ; fails

Any ideas?

Posted (edited)

haven't try it, please give a try.

$cmd3 = "'" & @ProgramFilesDir & '\mypath\postie.exe -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9' & "'"
Edited by Joon
Posted

For the record, Chr(34) is equivalent to the double-quote, in case you ever want to use single-quotes and double-quotes in the same line of code. You can say something like

chr(34) & "Speak softly and carry a big stick." & chr(34) & " -- Teddy Roosevelt"

Although the syntax is confusing, this statement is valid. It will produce the string:

"Speak softly... big stick." -- Teddy Roosevelt.

  • Developers
Posted

All, its all the same using any of these:

'"' &

"""" &

Chr(34) &

The essential item here is that when using @comspec which _RunDos() does, its is sometimes needed to enclose the whole command in Double Quotes.

This is what i did with the proposed code..

<_<

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

haven't try it, please give a try.

$cmd3 = "'" & @ProgramFilesDir & '\mypath\postie.exe -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9' & "'"
This one did not work. But it helped give me an idea to try. Thanks.
Posted

try:

$cmd3 = '""' & @ProgramFilesDir & '\mypath\postie.exe" -host:smtpserver -to:toemail -from:fromemail -s:"Testing" -msg:"Test" -v:9"'
_RunDOS($cmd3); fails
This one DID work. Thanks!
Posted

All, its all the same using any of these:

'"' &

"""" &

Chr(34) &

The essential item here is that when using @comspec which _RunDos() does, its is sometimes needed to enclose the whole command in Double Quotes.

This is what i did with the proposed code..

<_<

Thanks Jos, That's the explanation I was looking for. I just thought it would choke on doing the quote syntax like that. Interesting that they built the @comspec stuff to interpret it that way. Very good to know.

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
×
×
  • Create New...