Jump to content

reference variable which contain space into path


Go to solution Solved by Jos,

Recommended Posts

Posted

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
Posted (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 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.
  :)

Posted
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
Posted (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 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.
  :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...