Sign in to follow this  
Followers 0
jer

RunWait Syntax

10 posts in this topic

Any reason the following code:

RunWait("g:\test.exe -info > " & @TempDir & "\info.txt")

will NOT redirect to info.txt.

But this code will:

RunWait("g:\test.exe -info > e:\Temp\info.txt")

What am I missing???

Share this post


Link to post
Share on other sites



When having problems with strings inside a command like this its useually a good idea to try outputing the string in a msgbox or consolewrite to se what its actually doing

so try one of the following and youll probably find that @TempDir is differant to e:\Temp.

ConsoleWrite("g:\test.exe -info > " & @TempDir & "\info.txt" & @CR)
MsgBox(0,"","g:\test.exe -info > " & @TempDir & "\info.txt" & @CR)

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Follow Yoriz advise, must like it your @TempDir path has spaces.

Try it:

RunWait('g:\test.exe -info > "' & @TempDir & '\info.txt"')

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

Guys, Thanks for the quick replies. Before posting I put the following two strings in a msgbox:

msgbox(0, "", "g:\test.exe -info > E:\Temp\info.txt" & @LF & "g:\test.exe -info > " & @TempDir & "\_cd_info.txt")

The code above produced the following results:

g:\test.exe -info > E:\Temp\info.txt

g:\test.exe -info > E:\Temp\info.txt

I tried the single quote solution below.

RunWait('g:\test.exe -info > "' & @TempDir & '\info.txt"')

However, the redirection to info.txt did NOT occur.

Seems like I have run across a similar issue in the past, which I corrected with single quotes.

BTW, I did try ShellExecuteWait, but got the same results.

Just can't get to the bottom of this issue!

Any other thoughts???

Share this post


Link to post
Share on other sites

The only sugestion I can give you is to add the working directory.

RunWait('g:\test.exe -info > "' & @TempDir & '\info.txt"', @TempDir)

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Guys, Thanks for the quick replies. Before posting I put the following two strings in a msgbox:

msgbox(0, "", "g:\test.exe -info > E:\Temp\info.txt" & @LF & "g:\test.exe -info > " & @TempDir & "\_cd_info.txt")

The code above produced the following results:

g:\test.exe -info > E:\Temp\info.txt

g:\test.exe -info > E:\Temp\info.txt

I tried the single quote solution below.

RunWait('g:\test.exe -info > "' & @TempDir & '\info.txt"')

However, the redirection to info.txt did NOT occur.

Seems like I have run across a similar issue in the past, which I corrected with single quotes.

BTW, I did try ShellExecuteWait, but got the same results.

Just can't get to the bottom of this issue!

Any other thoughts???

Unfortunately, it was a nogo with the working directory. Must be an Autoit RunWait peculiarity as it works perfectly from the DOS command line.

Been banging my head against the wall for several hours on this one. May have to find another way to do the same thing!

Edited by jer

Share this post


Link to post
Share on other sites

If work fine from the command prompt try using @ComSpec with /k argument, which tells CMD.exe to open, run the specified command, then keep the window open. With the window open you may see what is the problem.

RunWait(@ComSpec & ' /k g:\test.exe -info > "' & @TempDir & '\info.txt"')

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

If work fine from the command prompt try using @ComSpec with /k argument, which tells CMD.exe to open, run the specified command, then keep the window open. With the window open you may see what is the problem.

RunWait(@ComSpec & ' /k g:\test.exe -info > "' & @TempDir & '\info.txt"')

Thanks for the tip. @ComSpec fixed the issue. Runs as expected now. Not sure why Autoit is requiring the @ComSpec macro. I thought this was only for DOS commands!!! Also, if the /k flag documented in help? I didn't see it with the RunWait function.

Share this post


Link to post
Share on other sites

Also, if the /k flag documented in help? I didn't see it with the RunWait function.

@ComSpec is the macro for CMD.EXE Open command prompt and type CMD.EXE /? it will give you all the switch or flag that you can use with @ComSpec.

If you want the command prompt window to close after running test.exe switch /k for /c.


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

@ComSpec is the macro for CMD.EXE Open command prompt and type CMD.EXE /? it will give you all the switch or flag that you can use with @ComSpec.

If you want the command prompt window to close after running test.exe switch /k for /c.

Great! Thanks again for your help!

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