Sign in to follow this  
Followers 0
Particle

_RunDOS() Help

12 posts in this topic

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?

Share this post


Link to post
Share on other sites



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. <_<

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#5 ·  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

Share this post


Link to post
Share on other sites

try:

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

<_<


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0