harle Posted December 27, 2005 Share Posted December 27, 2005 Hi,I am writing a script ATM so that I can mount images into daemon tools automatically and run an application (i.e. the game that is associated with the mounted image.) I have also given the script the ability to read from an INI file, to find the location of the mounted image and which executable to run etc.My problem is specifying which INI file to read from an external parameter/switch.For Example"c:\Program Files\image mounter\my script.au3" -Quake4So this would read the Quake4 INI file and feed the variables into the script that way.Is there any way to do this?Many Thanks Link to comment Share on other sites More sharing options...
nfwu Posted December 27, 2005 Share Posted December 27, 2005 Copied from the help file: AutoIt > Using AutoIt > Running Scripts Command Line Parameters The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way. $CmdLine[0] is number of parameters $CmdLine[1] is param 1 (after the script name) $CmdLine[2] is param 2 etc ... $CmdLine[$CmdLine[0]] is one way to get the last parameter... So if your script is run like this: AutoIt3.exe myscript.au3 param1 "this is another param" $CmdLine[0] equals... 2 $CmdLine[1] equals... param1 $CmdLine[2] equals... this is another param @ScriptName equals... myscript.au3 In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example: $CmdLineRaw equals... myscript.au3 param1 "this is another param" TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
themax90 Posted December 27, 2005 Share Posted December 27, 2005 (edited) Here is a quick sample, more effecient ways are avialible, this is just an example as too what you can do. Select Case $CmdLine[0] = 1 Select Case $CmdLine[1] = "-e" MsgBox(0, "Parameter", $CmdLine[1] & " is correct") Case Else MsgBox(16, "Parameter", $CmdLine[1] & " is not correct.") EndSelect Case Else ; Run Without Parameters MsgBox(0, "Parameter", "No Parameters") EndSelect AutoIt Smith Edited December 27, 2005 by AutoIt Smith 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