NTKBO Posted April 15, 2006 Share Posted April 15, 2006 Attempting to run a DOS level program and send it's output to a Text file in that users 'My Documents' folder. The line I'm trying: $RarSlave = Run(@StartupDir & "\rarslave.exe>" & @MyDocumentsDir & "\RarSlave.log", @StartupDir & "\") results in a 'failure ro run' error. Previously, I used autoit to generate a batch file to perform this, but that is a sloppy solution, and sometimes results in 'abandoned' temp files. A purer autoit solution would be nicer. Link to comment Share on other sites More sharing options...
MHz Posted April 15, 2006 Share Posted April 15, 2006 (edited) Try adding a space before and after your redirection operator and see if that helps. AutoIt not not be able to interpret which is program and with is switch. Edit: It may work better using comspec $RarSlave = Run(@ComSpec & ' /c "' & @StartupDir & '\rarslave.exe" > "' & _ @MyDocumentsDir & '\RarSlave.log"', @StartupDir & "\", @SW_HIDE) Edited April 15, 2006 by MHz Link to comment Share on other sites More sharing options...
NTKBO Posted April 15, 2006 Author Share Posted April 15, 2006 (edited) It may work better using comspecThis seems to get it to run with out error, but I can't get it to send the output to the log file in 'My Documents' yet.Thanks for your help !Yes, I did put your codce as a single line. Edited April 15, 2006 by NTKBO Link to comment Share on other sites More sharing options...
MHz Posted April 15, 2006 Share Posted April 15, 2006 Perhaps this may work $RarSlave = Run(@ComSpec & ' /c "' & @StartupDir & '\rarslave.exe" > RarSlave.log', @MyDocumentsDir, @SW_HIDE) Link to comment Share on other sites More sharing options...
NTKBO Posted April 15, 2006 Author Share Posted April 15, 2006 Perhaps this may work $RarSlave = Run(@ComSpec & ' /c "' & @StartupDir & '\rarslave.exe" > RarSlave.log', @MyDocumentsDir, @SW_HIDE) That was the ticket. I never would have thought of changing the working directory. The quote sequences can also get 'intimidating'. Thank you! Link to comment Share on other sites More sharing options...
NTKBO Posted April 17, 2006 Author Share Posted April 17, 2006 Now that it runs it from the internal command, it doesn't seem to 'see' it the same way. $RarSlave = Run(@ComSpec & ' /c "' & @StartupDir & '\rarslave.exe" > RarSlave.log', @MyDocumentsDir, @SW_HIDE) WinActivate($RarSlave) ;Show GUI and so forth While ProcessExists($RarSlave) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case Else ;;; EndSelect WEnd It initiates the WEnd statement while the Process still exists. Link to comment Share on other sites More sharing options...
NTKBO Posted April 23, 2006 Author Share Posted April 23, 2006 Perhaps this may work $RarSlave = Run(@ComSpec & ' /c "' & @StartupDir & '\rarslave.exe" > RarSlave.log', @MyDocumentsDir, @SW_HIDE) This line DOES cause a console window to open, and DOES create an empty log file in my documents, but the intended program does not actually run. The program it runs is available from here for free. If this command was working, the log file would at least have the welcome message from the child program. Any help would be appreciated! Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 24, 2006 Share Posted April 24, 2006 (edited) This line DOES cause a console window to open, and DOES create an empty log file in my documents, but the intended program does not actually run. The program it runs is available from here for free. If this command was working, the log file would at least have the welcome message from the child program. Any help would be appreciated! Change the /c to /k so the CMD window will be left open after the command executes. This will let you see if there are helpful errors going to the console. You can also put MsgBox() in for debug to make sure the command line is coming out as expected: $ExtCmd = @ComSpec & ' /k "' & @StartupDir & '\rarslave.exe" > RarSlave.log' MsgBox(64, "Debug", "The following command will be sent:" & @CRLF & $ExtCmd) $RarSlave = Run($ExtCmd, @MyDocumentsDir, @SW_HIDE) WinWait("RAR Slave") WinActivate("RAR Slave") ;Show GUI and so forth While ProcessExists($RarSlave) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case Else ;;; EndSelect WEnd WinWait() will keep you from moving on before things really are running. Your $RarSlave is the process ID, not the window name. Once the process is running, there may be some time before the window is open. So I sustituted the window title (which was only a guess) for WinWait() and WinActivate(). Edited April 24, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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