CutterButter Posted December 31, 2024 Posted December 31, 2024 I want to store path which contains spaces into variable called 'path' while executable file to another one called 'exe', e.g. I want to run this executable with parameters via Runwait command referencing variable Local Const $path= "C:\Program Files\my program with space\" Local Const $exe= "test.exe" $command = $path & $exe & " /e" & "test.txt" Runwait(@ComSpec & " /c " & $command , @TempDir, @SW_HIDE) "/e test.txt" are two input parameters that is I'd like to run this command : "C:\Program Files\my program with space\test.exe" /e test.txt When I run Runwait I think It failed because path doesn't include double quote . What can you suggest me ?
Developers Jos Posted December 31, 2024 Developers Posted December 31, 2024 (edited) try: Quote Local Const $path= "C:\Program Files\my program with space\" Local Const $exe= "test.exe" $command = $path & $exe & " /e " & "test.txt" Runwait(@ComSpec & ' /c "' & $command & '"' , @TempDir, @SW_HIDE) Edited December 31, 2024 by Jos 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.
CutterButter Posted December 31, 2024 Author Posted December 31, 2024 52 minutes ago, Jos said: try: Local Const $path= "C:\Program Files\my program with space\" Local Const $exe= "test.exe" $command = $path & $exe & " /e " & "test.txt" Runwait(@ComSpec & ' /c "' & $command & '"' , @TempDir, @SW_HIDE) I took advantage of part of your code because it didn't work I found out only "C:\Program Files\my program with space\test.exe" has to be included into double quotes so I stored it into command variable and the other parameteres into command2 This works: Local Const $path= "C:\Program Files\my program with space\" Local Const $exe= "test.exe" $command = $path & $exe $command2 = " /e " & "test.txt" Runwait(@ComSpec & ' /c "' & $command & '"' & command2, @TempDir, @SW_HIDE) What do you think? Do you another way ? Thank you for your precious support
Developers Solution Jos Posted December 31, 2024 Developers Solution Posted December 31, 2024 (edited) 18 minutes ago, CutterButter said: What do you think? Do you another way ? Looks good to me. Maybe a small change to avoid parameter mistakes added the space in the last line instead of the $command2 variable? Local Const $path = "C:\Program Files\my program with space\" Local Const $exe = "test.exe" $command = $path & $exe $parameters = "/e test.txt" Runwait(@ComSpec & ' /c "' & $command & '" ' & parameters, @TempDir, @SW_HIDE) Edited December 31, 2024 by Jos 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.
CutterButter Posted December 31, 2024 Author Posted December 31, 2024 28 minutes ago, Jos said: Looks good to me. Maybe a small change to avoid parameter mistakes added the space in the last line instead of the $command2 variable? Local Const $path = "C:\Program Files\my program with space\" Local Const $exe = "test.exe" $command = $path & $exe $parameters = "/e test.txt" Runwait(@ComSpec & ' /c "' & $command & '" ' & parameters, @TempDir, @SW_HIDE) that's good!
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