Sign in to follow this  
Followers 0
rmuk

Autoit Newbie :(

6 posts in this topic

Hey guys,

Apologies for the noobish question but I've just not been able to figure out how to do this... ;)

What I want to do is execute my program with a custom command line parameter - this parameter is actually read from a .ini file. Here's an example of how the code would look - not the actual code, this is more a visual representation of how the script should look in my head. :evil:

;Read custom command line parameter from the ini file

$CustomParameter = Iniread("C:\Test\File.ini", "Group", "Value","Error")

;Set custom command line parameter

$CmdLine[0] = $CustomParameter

;Run my program with the custom parameter

Run("Program.exe", $CmdLine")

Of course, this doesn't work. Can't assign values to constants error and I just don't understand the documentation for $CmdLine!

If someone could explain how to go about doing this in a newbie friendly way, I'd appreciate it greatly.

Also... I would consider the possibility of using an "Open With" script for autoit. Basically, the files the program is reading are a custom format. Is there perhaps some way I could write a script in autoit which makes my own program open the custom files?

Hope some of that made sense, grateful for any help - cheers and Happy New Year! :evil:

Share this post


Link to post
Share on other sites



Perhaps I'm not reading this correctly, but I don't think a program/script can read from a file parameters to be passed to it on its command line. Maybe you mean it will run itself again, or start another program? Additionally, CmdLine[0] is an array variable that contains the number of command line arguments, and ShellExecute would be used in this case, not Run.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Hiya Snowmaker, thanks for taking the time to reply. :evil:

Ah I hadn't noticed the ShellExecute vs. Run thing, that's certainly helpful!

To elaborate a bit more. The goal of the script is to make it automatically open my convertor.exe which is a small DOS conversion program. When Autoit opens my converter.exe, I need to give it the filename I want to convert, as a parameter. So, here's a rough example:

My autoit script and the conversion program I'm "interacting" with are both in C:\MyApp

The file I want to convert is C:\Files\Test\File.rt8

The autoit script reads from an external ini (which is created by another program, not applicable to this example) in order to get the full path name and file name of the file to convert.

The autoitscript runs my converter.exe and tells it the path and filename of the file to convert.

It sounds a lot simpler to explain in my head ;)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I think i might be getting the jist of what your saying or maybe not but this is what i would think the script would looke something like

$oFile = FileOpen("FileName.INI",0)
$CustomParameter = FileReadLine($oFile,1) ;1 would be the line number that the file path is on
Run('"Program.exe" "' & $CustomParameter & '"')

really you don't need $CmdLine[] unless your actually passing the compiled autoit script a command like CompliedScript.exe "PathToINI"

if you wanted that it would look like this

If $CmdLine[0] = "" Then
     MsgBox(16,"Error!",'No INI File was specified, Please use format ' & @ScriptName & ' "PathToINI"')
Else
     $oFile = FileOpen($CmdLine[1],0)
EndIf
$CustomParameter = FileReadLine($oFile,1) ;1 would be the line number that the file path is on
Run('"Program.exe" "' & $CustomParameter & '"')

is this kindof what you wer talking about?

Edited by tlman12

Share this post


Link to post
Share on other sites

Well I think this would work..

ShellExecute("Program.exe", $CustomParameter)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Thanks folks, going to try those suggestions now and see how it goes, will report back - much appreciated ;)

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