nevodj Posted April 28, 2011 Share Posted April 28, 2011 Hi Can someone help me, i can not get command line parameters to work with AutoIT. If I write a simple script like: MsgBox(0,"Parameters", $CmdLine[1]) And convert it to an exe, then run it with any parameter e.g. abc123, it opens the C:\Documents folder? my script is complete apart from this bit, can someone help! thanks Link to comment Share on other sites More sharing options...
hannes08 Posted April 28, 2011 Share Posted April 28, 2011 Hi nevodj, if you use paramaters that have spaces / blanks in it you need to quote them. e.g. script.exe parameter1 "parameter 2" Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
nevodj Posted April 28, 2011 Author Share Posted April 28, 2011 Thanks Hannes, i created a basic script as above to test this function. ============================ MsgBox(0,"Parameters", $CmdLine[1]) ============================ Then compiled it to 'test.exe' on my desktop. when i run this from the command line using C:\Documents and Settings\User\Desktop\test.exe param1 or C:\Documents and Settings\User\Desktop\test.exe "param1" it opens the C:\Documents folder?! shouldnt it display a msgbox with "param1" in the lines? when i run it with no args it comes up "Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" THe help file on this topic is not very comprehensive. appreciate your help Link to comment Share on other sites More sharing options...
UEZ Posted April 28, 2011 Share Posted April 28, 2011 This should work properly: Global $parameter If Not $CmdLine[0] Then $parameter = "No parameter(s) was/were entered" Else For $i = 1 To $CmdLine[0] $parameter &= $CmdLine[$i] & @LF Next EndIf MsgBox(0, "Test", "Parameter(s) entered: " & @CRLF & $parameter) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
nevodj Posted April 28, 2011 Author Share Posted April 28, 2011 Thanks UEZ, If i compile your script to C:\Documents and Settings\User\Desktop\test.exe and then run it by typing the following in Run - C:\Documents and Settings\User\Desktop\test.exe testparam It still opens the C:\Documents folder. What am i doing wrong? If i dont specify any args i get the msgbox saying none specified. Thanks Link to comment Share on other sites More sharing options...
enaiman Posted April 29, 2011 Share Posted April 29, 2011 Try this: "C:\Documents and Settings\User\Desktop\test.exe" testparam For some reason, your "Run" is considering the white spaces in the file path as parameter delimiters - by enclosing the path in quotes, you will force it to be recognized as a single entity. You can test it this way: put your script on c:\ then run it - you'll see that it works. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
nevodj Posted April 29, 2011 Author Share Posted April 29, 2011 Ah sweet, thanks heaps enaiman! 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