Page 1 of 1

Interpolation of Run command with variables

Posted: 07 Mar 2019 01:42
by hermhart
Just wondering if anyone has any idea on how to get this to work?

Code: Select all

  run 'cmd /c "c:\Program Files\blah\blah new\blah.exe" -list "$item" > $testFile';
Seems like any way that I want to quote it I can't get it to work. If I use single quotes, the the variables that I defined do not resolve, and if I use double or triple quotes, then I get c:\Program can't find...

Anyone have any ideas?

Re: Interpolation of Run command with variables

Posted: 07 Mar 2019 06:17
by bdeshi

Code: Select all

  run 'cmd /c  "c:\Program Files\blah\blah new\blah.exe"  -list  "$item"  > $testFile'; // yours
  run "cmd /c ""c:\Program Files\blah\blah new\blah.exe"" -list ""$item"" > $testFile"; // mended

Re: Interpolation of Run command with variables

Posted: 08 Mar 2019 00:18
by hermhart
I tried as you suggested, but still get the following message:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Strange thing is, when I Run Script in Step Mode, at the point where it is going to run that command, the command looks perfectly set up, but still fails with the above message. Seems like for me, using single quotes on the outside worked, but it just wouldn't resolve the variables that I defined. Can you think of a way around that so that I can use the single quotes?

Re: Interpolation of Run command with variables

Posted: 08 Mar 2019 02:51
by highend
You did use the second line, didn't you?

Re: Interpolation of Run command with variables

Posted: 08 Mar 2019 03:17
by hermhart
LOL, yes I did. Trust me, with as many ways as I have tried it, I was not going to mess up testing that option out. :lol:

Is there a way to interpolate the variables that I have defined within single quotes?

Re: Interpolation of Run command with variables

Posted: 08 Mar 2019 03:53
by highend
Is there a way to interpolate the variables that I have defined within single quotes?
No, that's their purpose.

Try this

Code: Select all

run "cmd /c (""c:\Program Files\blah\blah new\blah.exe"" -list ""$item"") > ""$testFile""";

Re: Interpolation of Run command with variables

Posted: 09 Mar 2019 00:36
by hermhart
That did it!

Why the parenthesis only around what you did?

Thank you so much for your help, guys.