Jump to content
Sign in to follow this  
norjms

RunWait with variable from ini file

Recommended Posts

norjms

Hello I'm having problems getting RunWait to pass variable from an ini file. Anyone know what I doing wrong?

The command that needs passed is: AnyTool2.exe ripraw G: E:\Store This command is changable by the user to set it to their paths.

AutoIt File

;Define the DVD drive letter
GLOBAL $INPUT = IniRead("configure.ini", "section1", "key", "NotFound")
;Define the path to store the files
GLOBAL $OUTPUT = IniRead("configure.ini", "section2", "key", "NotFound")
;Wait until drive is ready
While DriveStatus( $INPUT ) = "NOTREADY"
WEnd
While DriveStatus( $INPUT ) = "UNKNOWN"
WEnd
;Once drive is ready
If DriveStatus( $INPUT ) = "READY" Then RunWait("AnyTool2.exe ripraw " $INPUT $OUTPUT )
;Done

The ini file

[section1]
Key=G:
[section2]
Key=E:\Store

Share this post


Link to post
Share on other sites
AdmiralAlkex

You concatenate strings by an ampersand "&" (see "Operators" in helpfile)

("AnyTool2.exe ripraw " & $INPUT & $OUTPUT)

Don't forget to a a space to between input and output, or was that an error in the example?

Share this post


Link to post
Share on other sites
norjms

You concatenate strings by an ampersand "&" (see "Operators" in helpfile)

("AnyTool2.exe ripraw " & $INPUT & $OUTPUT)

Don't forget to a a space to between input and output, or was that an error in the example?

Thanks for the reply, but it doesn't seem to work. The command windows just opens and closes way too fast to read. Anyother ideas? I mean did I declare the variables properly? Is there a way to hold the command windows open so I can see what command it is passing to debug?

Here is the changed code like you suggested

;Define the DVD drive letter
GLOBAL $INPUT = IniRead("configure.ini", "section1", "key", "NotFound")
;Define the path to store the DVD files
GLOBAL $OUTPUT = IniRead("configure.ini", "section2", "key", "NotFound")
;Wait until drive is ready
While DriveStatus( $INPUT ) = "NOTREADY"
WEnd
While DriveStatus( $INPUT ) = "UNKNOWN"
WEnd
;Once drive is ready
If DriveStatus( $INPUT ) = "READY" Then RunWait("AnyTool2.exe ripraw " & $INPUT & $OUTPUT)
;When done
;CDTray("G:", "open")

Share this post


Link to post
Share on other sites
norjms

I made sure my variable was correct by running this script.

;Define the DVD drive letter
GLOBAL $INPUT = IniRead("configure.ini", "section1", "key", "NotFound")
;Define the path to store the DVD files
GLOBAL $OUTPUT = IniRead("configure.ini", "section2", "key", "NotFound")

;Wait until drive is ready
While DriveStatus( $INPUT ) = "NOTREADY"
WEnd
While DriveStatus( $INPUT ) = "UNKNOWN"
WEnd
;Once drive is ready
If DriveStatus( $INPUT ) = "READY" Then RunWait("AnyTool2.exe ripraw G: E:\DVDRip")
;When done
;CDTray("G:", "open")

The script breaks if I try it like this

If DriveStatus( $INPUT ) = "READY" Then RunWait("AnyTool2.exe ripraw" & $INPUT & $OUTPUT)

Any solutions?

Share this post


Link to post
Share on other sites
PsaltyDS

Thanks for the reply, but it doesn't seem to work. The command windows just opens and closes way too fast to read. Anyother ideas? I mean did I declare the variables properly? Is there a way to hold the command windows open so I can see what command it is passing to debug?

You can start a new CMD.exe instance and use /k vice /c when passing the command line to have the console stay open after execution:
RunWait(@ComSpec & " /k AnyTool2.exe ripraw ...etc.")

I have MANY scripts that pass command lines, and as a general rule they are assembled in a single string variable before execution. This makes troubleshooting and especially verbose logging easier. Try something like this:

$sMyCommand = "AnyTool2.exe ripraw " & $INPUT & " " & $OUTPUT
MsgBox(64, "Debug", "$sMyCommand = " & $sMyCommand)
RunWait($sMyCommand)

Note that includes the space between parameters that AdmiralAlkex suggested.

:)


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
norjms

You can start a new CMD.exe instance and use /k vice /c when passing the command line to have the console stay open after execution:

RunWait(@ComSpec & " /k AnyTool2.exe ripraw ...etc.")

I have MANY scripts that pass command lines, and as a general rule they are assembled in a single string variable before execution. This makes troubleshooting and especially verbose logging easier. Try something like this:

$sMyCommand = "AnyTool2.exe ripraw " & $INPUT & " " & $OUTPUT
MsgBox(64, "Debug", "$sMyCommand = " & $sMyCommand)
RunWait($sMyCommand)

Note that includes the space between parameters that AdmiralAlkex suggested.

:)

You are my Hero! Thanks that worked like a charm.

Share this post


Link to post
Share on other sites
whim

maybe

RunWait("AnyTool2.exe ripraw " & $INPUT & " " & $OUTPUT)

still no joy ? then maybe your exe needs NTVDM:

RunWait(@ComSpec & " /c AnyTool2.exe ripraw " & $INPUT & " " & $OUTPUT)

hth,

whim

edit: sorry, slow typing here ...

Edited by whim

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  

×