Newbie2 Posted June 27, 2004 Share Posted June 27, 2004 (edited) How can I execute a script with parameters that the script will be able to use while running? All this using $CmdLine Can someone give me an example? Edited June 27, 2004 by Newbie2 Link to comment Share on other sites More sharing options...
Developers Jos Posted June 27, 2004 Developers Share Posted June 27, 2004 from the helpfile: AutoIt3.exe myscript.au3 param1 "this is another param" $CmdLine[0]= 2 $CmdLine[1] = "param1" $CmdLine[2] = "this is another param"Script example from the CompileAU3.au3 script: $V_ARG = "Valid Arguments are:" & @LF $V_ARG = $V_ARG & " /in ScriptFile " & @LF $V_ARG = $V_ARG & " /out Targetfile " & @LF $V_ARG = $V_ARG & " /icon IconFile " & @LF $V_ARG = $V_ARG & " /pass passphrase " & @LF $V_ARG = $V_ARG & " /comp 0 to 4 (Lowest to Highest) " & @LF For $X = 1 To $CMDLINE[0] $T_VAR = StringLower($CMDLINE[$X]) Select Case $T_VAR = "/?" Or $T_VAR = "/help" MsgBox(1, "Compile Aut2EXE", "Compile an AutoIt3 Script." & @LF & "commandline argument: " & $T_VAR & @LF & $V_ARG) Exit Case $T_VAR = "/in" $X = $X + 1 $SCRIPTFILE_IN = $CMDLINE[$X] Case $T_VAR = "/out" $X = $X + 1 $SCRIPTFILE_OUT = $CMDLINE[$X] Case $T_VAR = "/icon" $X = $X + 1 $INP_ICON = $CMDLINE[$X] Case $T_VAR = "/pass" $X = $X + 1 $INP_PASSPHRASE = $CMDLINE[$X] $INP_PASSPHRASE2 = $CMDLINE[$X] Case $T_VAR = "/compress" or $T_VAR = "/comp" $X = $X + 1 $INP_COMPRESSION = Number($CMDLINE[$X]) If $INP_COMPRESSION < 0 Or $INP_COMPRESSION > 4 Then $INP_COMPRESSION = "" Case $T_VAR = "/nodecompile" $INP_ALLOW_DECOMPILE = 0 Case Else MsgBox(1, "Compile Aut2EXE", "Wrong commandline argument: " & $T_VAR & @LF & $V_ARG) Exit EndSelect Next SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Newbie2 Posted June 27, 2004 Author Share Posted June 27, 2004 10x, JdeB for your good will, but... do you have an easier sample? It's too complicated for a newbie like me... Link to comment Share on other sites More sharing options...
Developers Jos Posted June 27, 2004 Developers Share Posted June 27, 2004 (edited) Its not that difficult... Here's a basic one.... create the below script and compile it... Msgbox(0,'param1',cmdline[1]) Msgbox(0,'param2',cmdline[2])Then run it from the commandprompt: yourscript.exe param1 param2 ok ? Edited June 27, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Newbie2 Posted June 27, 2004 Author Share Posted June 27, 2004 OK, now! 10x Link to comment Share on other sites More sharing options...
BlueScreen Posted June 27, 2004 Share Posted June 27, 2004 Hi Newbie2, I don't get it. I have copied the 2 lines, compiled the script and nothing works! WHYYYYYYYYYYYY? :iamstupid: Link to comment Share on other sites More sharing options...
Valik Posted June 27, 2004 Share Posted June 27, 2004 Maybe because you didn't actually pass the script 2 parameters? Link to comment Share on other sites More sharing options...
BlueScreen Posted June 27, 2004 Share Posted June 27, 2004 Shouldn't it beMsgbox(0,'param1',$cmdline[1]) Msgbox(0,'param2',$cmdline[2]) With the $ sign? Link to comment Share on other sites More sharing options...
Developers Jos Posted June 27, 2004 Developers Share Posted June 27, 2004 (edited) yes it should be with the $ .... I just typed it online since he asked for a simple example.... You also ofcource need to make sure that 2 parameters are passed or else you get an error... Edited June 27, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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