Interpolation of Run command with variables

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
hermhart
Posts: 213
Joined: 13 Jan 2015 18:41

Interpolation of Run command with variables

Post 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?
Last edited by bdeshi on 07 Mar 2019 06:15, edited 1 time in total.
Reason: inserted codeblock

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Interpolation of Run command with variables

Post 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
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

hermhart
Posts: 213
Joined: 13 Jan 2015 18:41

Re: Interpolation of Run command with variables

Post 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?

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Interpolation of Run command with variables

Post by highend »

You did use the second line, didn't you?
One of my scripts helped you out? Please donate via Paypal

hermhart
Posts: 213
Joined: 13 Jan 2015 18:41

Re: Interpolation of Run command with variables

Post 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?

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Interpolation of Run command with variables

Post 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""";
One of my scripts helped you out? Please donate via Paypal

hermhart
Posts: 213
Joined: 13 Jan 2015 18:41

Re: Interpolation of Run command with variables

Post by hermhart »

That did it!

Why the parenthesis only around what you did?

Thank you so much for your help, guys.

Post Reply