llssff Posted July 2, 2021 Share Posted July 2, 2021 I am trying to run an executable on a file that is given as a parameter of the AutoIt script. "auto3.exe myScript.au3 someFilePath" Quote Run( 'myExecutable.exe $CmdLine[1]' ) The issue is the quotes need to be there since Run takes one parameter, but with them there autoIt recognizes the parameter var as a String. Anyone have tips on how to make this work? or a better way to pass the parameter in? Link to comment Share on other sites More sharing options...
Luke94 Posted July 2, 2021 Share Posted July 2, 2021 Run('myExecutable.exe "' & $CmdLine[1] & '"') Above the parameter is wrapped in quotation's. Below, without. Run('myExecutable.exe ' & $CmdLine[1]) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 3, 2021 Share Posted July 3, 2021 @llssff @Luke94 You can use ExpandVarStrings option too Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Musashi Posted July 3, 2021 Share Posted July 3, 2021 1 hour ago, FrancescoDiMuro said: You can use ExpandVarStrings option too Hi Francesco As far as I know, ExpandVarStrings does not work with arrays : Example : Opt("ExpandVarStrings", 1) ; 0=don't expand(default), 1=do expand If $CMDLINE[0] Then ConsoleWrite("ExpandVar : $CMDLINE[1]$" & @CRLF) ConsoleWrite("Normal : " & $CMDLINE[1] & @CRLF) Else ConsoleWrite("Error : no CMDLine parameters passed" & @CRLF) EndIf see : FrancescoDiMuro 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Musashi Posted July 3, 2021 Share Posted July 3, 2021 @llssff : Here is a test script that considers the answers from @Luke94 und @FrancescoDiMuro : (use clock.au3 as a parameter) Opt("ExpandVarStrings", 1) ; 0=don't expand(default), 1=do expand ; Example : uses the interpreter AutoIt3.exe (as macro) : Local $sMyExecutable = @AutoItExe Local $sMyScript ; Check, if a commandline parameter was passed (otherwise an error will occur). If $CMDLINE[0] Then ; Example : path to the script : ..\AutoIt3\Examples\GUI\Advanced\ : ; ==> Use clock.au3 as CMDLine[1] (to quit the clock, use ESC) $sMyScript = StringRegExpReplace(@AutoItExe, "(?i)AutoIt3.exe$", "") & "Examples\GUI\Advanced\" & $CMDLINE[1] ; ==> Comment out one of the variants at a time : ; Variant 1 : start 'normal' : Run($sMyExecutable & ' "' & $sMyScript &'"') ; Variant 2 : use 'ExpandVarStrings' : ;Run($sMyExecutable & ' "$sMyScript$"') Else ConsoleWrite("Error : no CMDLine parameters passed" & @CRLF) EndIf "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." 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