jer Posted April 5, 2010 Share Posted April 5, 2010 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??? Link to comment Share on other sites More sharing options...
Yoriz Posted April 5, 2010 Share Posted April 5, 2010 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. Link to comment Share on other sites More sharing options...
Danny35d Posted April 5, 2010 Share Posted April 5, 2010 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 Link to comment Share on other sites More sharing options...
jer Posted April 5, 2010 Author Share Posted April 5, 2010 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??? Link to comment Share on other sites More sharing options...
Danny35d Posted April 5, 2010 Share Posted April 5, 2010 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 Link to comment Share on other sites More sharing options...
jer Posted April 5, 2010 Author Share Posted April 5, 2010 (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 April 5, 2010 by jer Link to comment Share on other sites More sharing options...
Danny35d Posted April 5, 2010 Share Posted April 5, 2010 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 Link to comment Share on other sites More sharing options...
jer Posted April 6, 2010 Author Share Posted April 6, 2010 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. Link to comment Share on other sites More sharing options...
Danny35d Posted April 6, 2010 Share Posted April 6, 2010 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 Link to comment Share on other sites More sharing options...
jer Posted April 6, 2010 Author Share Posted April 6, 2010 @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! 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