rmuk Posted December 31, 2009 Share Posted December 31, 2009 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. ;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! Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 31, 2009 Share Posted December 31, 2009 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. Link to comment Share on other sites More sharing options...
rmuk Posted December 31, 2009 Author Share Posted December 31, 2009 Hiya Snowmaker, thanks for taking the time to reply. 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 Link to comment Share on other sites More sharing options...
tlman12 Posted December 31, 2009 Share Posted December 31, 2009 (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 December 31, 2009 by tlman12 Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 31, 2009 Share Posted December 31, 2009 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. Link to comment Share on other sites More sharing options...
rmuk Posted December 31, 2009 Author Share Posted December 31, 2009 Thanks folks, going to try those suggestions now and see how it goes, will report back - much appreciated 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