moscas Posted September 21, 2010 Share Posted September 21, 2010 sorry for my English I wonder if there is a function to enable the passing of parameters between executables (eg batch dos variables are made with% 1% 2% 3 etc.) Link to comment Share on other sites More sharing options...
Varian Posted September 21, 2010 Share Posted September 21, 2010 (edited) If you mean starting another program/script from another script that's what Run and ShellExecute do already. egRun('regedit.exe /s "' @TempDir & '\regfile.reg"')"/s" and "@Tempdir\regfile.reg" are paramters for regedit.exe orShellExecute(@MyDocumentsDir & '\wordfile.doc', '', '', 'open')passes "@MyDocumentsDir\wordfilefile.doc" to the default handler for the .doc extension with the verb "open" as opposed to say "print" Edited September 21, 2010 by Varian Link to comment Share on other sites More sharing options...
Juvigy Posted September 21, 2010 Share Posted September 21, 2010 From the help file: 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" If the script was compiled it would have been run like this: myscript.exe param1 "this is another param" $CmdLineRaw equals... param1 "this is another param" Note that $CmdLineRaw just return the parameters. Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line. Link to comment Share on other sites More sharing options...
moscas Posted September 21, 2010 Author Share Posted September 21, 2010 (edited) If you mean starting another program/script from another script that's what Run and ShellExecute do already. egRun('regedit.exe /s "' @TempDir & '\regfile.reg"')"/s" and "@Tempdir\regfile.reg" are paramters for regedit.exe orShellExecute(@MyDocumentsDir & '\wordfile.doc', '', '', 'open')passes "@MyDocumentsDir\wordfilefile.doc" to the default handler for the .doc extension with the verb "open" as opposed to say "print" ok, this is correct, but if I wanted to run an executable AutoIt variable settings that must pass before the executable? es. one.exe two.exe $Myname = "moscas" ShellExecute (@scriptdir & "\two.exe",'','', $myname) msgbox (0, "Test", "Your Name is" & ????) Edited September 21, 2010 by moscas Link to comment Share on other sites More sharing options...
Juvigy Posted September 21, 2010 Share Posted September 21, 2010 Code1 $Myname = "moscas" ShellExecute (@scriptdir & "\two.exe"&''&$myname) Code2 msgbox (0, $CmdLineRaw, "Your Name is:" & $CmdLine[1]) Link to comment Share on other sites More sharing options...
moscas Posted September 21, 2010 Author Share Posted September 21, 2010 if i run one.exe: Can't find "c:\autoit\mydoc\test01\two.exemoscas" Link to comment Share on other sites More sharing options...
Juvigy Posted September 21, 2010 Share Posted September 21, 2010 Change this . The space between two.exe and myname was missing ShellExecute (@scriptdir & "\two.exe"&' '&$myname) Link to comment Share on other sites More sharing options...
moscas Posted September 21, 2010 Author Share Posted September 21, 2010 (edited) always equal Can't find "c:\autoit\mydoc\test01\two.exe moscas" sorry but I can not understand how it work ... there are months that I bang my head ...perhaps wrong to declare variables in two.exe? EDIT: found!!! one.exe $myname = "moscas" ShellExecute (@scriptdir & "\two.exe",$myname) two.exe msgbox (0, $CmdLineRaw, "Your Name is:" & $CmdLine[1]) for must one.exe $myname = "moscas" $secondname = "second" ShellExecute (@scriptdir & "\two.exe",$myname & ' ' &$secondname) two.exe msgbox (0, $CmdLineRaw, "Your Name is:" & $CmdLine[1]) msgbox (0, $CmdLineRaw, "Your Second Name is:" & $CmdLine[2]) Edited September 21, 2010 by moscas Link to comment Share on other sites More sharing options...
Juvigy Posted September 21, 2010 Share Posted September 21, 2010 Ah yes , forgot to change shellexecute to Runcmd... Link to comment Share on other sites More sharing options...
moscas Posted September 21, 2010 Author Share Posted September 21, 2010 perfect, and now, how can I handle the @error if the variable $ CmdLine [1] is not readable? (Eg running two.exe double click instead of it run by one.exe?) Link to comment Share on other sites More sharing options...
Juvigy Posted September 21, 2010 Share Posted September 21, 2010 Maybe : If $CmdLine[0]<>0 Then msgbox (0, $CmdLineRaw, "Your Name is:" & $CmdLine[1]) 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