Sign in to follow this  
Followers 0
NTKBO

Run Command Error

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by MHz

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It may work better using comspec

This 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 by NTKBO

Share this post


Link to post
Share on other sites

Perhaps this may work

$RarSlave = Run(@ComSpec & ' /c "' & @StartupDir & '\rarslave.exe" > RarSlave.log', @MyDocumentsDir, @SW_HIDE)

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

#8 ·  Posted (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().

:think:

Edited 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

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