dmorand Posted September 23, 2008 Share Posted September 23, 2008 I have a script that I created that I just compiled as an exe. I would like to pass 3 arguments to the exe and assign them to variables I have setup. How would I go about doing this? I'm fairly new to writing scripts so sorry if this is dumb. Link to comment Share on other sites More sharing options...
cartman380 Posted September 23, 2008 Share Posted September 23, 2008 I have a script that I created that I just compiled as an exe. I would like to pass 3 arguments to the exe and assign them to variables I have setup. How would I go about doing this? I'm fairly new to writing scripts so sorry if this is dumb.Go to the help file goto index and type in Command Line Parameters and it gives you all the information about using command line parameters. Link to comment Share on other sites More sharing options...
Kip Posted September 23, 2008 Share Posted September 23, 2008 I'm fairly new to writing scripts so sorry if this is dumb.That's not an excuse for NOT searching. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
dmorand Posted September 23, 2008 Author Share Posted September 23, 2008 Sorry I did search, I just couldn't find anything, I'll make sure I search better next time. Link to comment Share on other sites More sharing options...
Kip Posted September 23, 2008 Share Posted September 23, 2008 Sorry I did search, I just couldn't find anything,I bet you searched on the forums, not the help file. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
dmorand Posted September 23, 2008 Author Share Posted September 23, 2008 I bet you searched on the forums, not the help file.Yes that's exactly what I did. I haven't had good luck ever with application help files, that's why. Link to comment Share on other sites More sharing options...
DaRam Posted September 23, 2008 Share Posted September 23, 2008 Search for "CmdLine" and pick the first item on the list -> "Running Scripts".Yes that's exactly what I did. I haven't had good luck ever with application help files, that's why. Link to comment Share on other sites More sharing options...
bouncingmolar Posted September 26, 2008 Share Posted September 26, 2008 Sorry I did search, I just couldn't find anything, I'll make sure I search better next time.Thanks Dmorand for taking the heat. I was almost going to send another question about this until I found your post. My problem was that I didn't know that command line was called command line so i didn't know what to search for. Link to comment Share on other sites More sharing options...
bouncingmolar Posted September 26, 2008 Share Posted September 26, 2008 Perhaps I don't have a very good understanding of Cmdline paramaters but Can cmd lines be injected into an already running script? Link to comment Share on other sites More sharing options...
martin Posted September 26, 2008 Share Posted September 26, 2008 (edited) Perhaps I don't have a very good understanding of Cmdline paramaters but Can cmd lines be injected into an already running script?Not in a straightforward way.Say you have a script alredy running.Then you run another instance but pass it the parameters. Then the second one knows what the parameters are, it can detect that there is already a version running so then it can tell the previous version what the parameters are and close. To tell the other script what the parameters are it can use messages (my preference) or some other method. There are many other methods. For example if the script has an edit then you can use ControlCommanbd to send text to the edit, then the script can detect the change and read it. Or you could write a file with the data in it, the other script detects the file, reads it and deletes it. Edited September 26, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
ob2s Posted July 23, 2009 Share Posted July 23, 2009 How do you loop through the args ? for example args are one two three four five I need the first arg that I can ref using %1%, but then I need take two three four five and stick them together in one variable. The total number of arguments always varies. I know %0% will count the args, but I am not sure how to make the variable I am looking for. In unix I just var=`echo $* |sed "s/arg1 //g"` just to clarify what I need to do. Thanks Link to comment Share on other sites More sharing options...
sksbir Posted July 23, 2009 Share Posted July 23, 2009 How do you loop through the args ? for example args are one two three four five I need the first arg that I can ref using %1%, but then I need take two three four five and stick them together in one variable. The total number of arguments always varies. I know %0% will count the args, but I am not sure how to make the variable I am looking for. In unix I just var=`echo $* |sed "s/arg1 //g"` just to clarify what I need to do. Thanks Hello, you have to make a concatenation loop, something like this: $OTHERARGS="" for $CPT=2 to $CMDLINE[0] $OTHERARGS&=$CMDLINE[$CPT] next msgbox(0,"test","1st arg=" & $CMDLINE[1] & @crlf & "Other args=" & $OTHERARGS) Link to comment Share on other sites More sharing options...
carriecelery Posted September 15, 2015 Share Posted September 15, 2015 Six years later, this is how I accessed the arguments within my script:$valueOne = _Args("/argumentOne", ":") $valueTwo = _Args("/argumentTwo", ":") ConsoleWrite($valueOne) ConsoleWrite($valueTwo) Func _Args($argument, $delimiter) If Ubound($CmdLine) > 1 Then For $i = 1 To UBound($CmdLine)-1 Step 1 If StringInStr($CmdLine[$i], $argument, 0) Then If StringInStr($CmdLine[$i], $delimiter, 0) Then $value = StringSplit($CmdLine[$i], $delimiter) Return $value[2] EndIf EndIf Next EndIf EndFuncAnd this is how I added the arguments when calling the script:"C:\install\AutoIt3.exe" "C:\ArgsTest.au3" /argumentOne:MyFirstValue /argumentTwo:MySecondValue TechShock 1 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 15, 2015 Moderators Share Posted September 15, 2015 6 years later, and the OP hasn't even been active in that 6 years. Thanks for demonstrating why we don't necro old posts... "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
erblemoof Posted January 11, 2016 Share Posted January 11, 2016 (edited) Six years later, this is how I accessed the arguments within my script:Thanks, this was the first result when searching Google keywords 'pass arguments to script site:www.autoitscript.com'. I found your post extremely helpful. It saved me a bunch of time. Edited January 11, 2016 by erblemoof Link to comment Share on other sites More sharing options...
faldo Posted November 8, 2017 Share Posted November 8, 2017 Howdy, Thanx for this small but usefull UDF. By adding the flag 1 to stringsplit you can use more than one character as delimiter (ie. /argumentOne::"c:\temp\outputfile.txt") Func _Args($argument, $delimiter) If Ubound($CmdLine) > 1 Then For $i = 1 To UBound($CmdLine)-1 Step 1 If StringInStr($CmdLine[$i], $argument, 0) Then If StringInStr($CmdLine[$i], $delimiter, 0) Then $value = StringSplit($CmdLine[$i], $delimiter, 1) Return $value[$value[0]] EndIf EndIf Next EndIf EndFunc Cheers! Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API 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