Page 1 of 1

How to properly use Run, Runq, Run Quote() ?

Posted: 29 Jan 2025 14:46
by eil
Can smbd please make a "300% guaranteed to work" instruction on how to use these?

Every single time i deal with this command(variation), i stumble upon problem to make it work. Obviously it's 'cause i'm noob and don't get something, plus complexity of quote-rules, but somehow that's The Only command i ever have problem with, ending up spending hours, trying all variants i can imagine, till "maybe" one will work.

The legend:
<tool>
<target>
<result>
==all these paths can have spaces!
<-param1> <-param2> (several of those separated by spaces)
<work_dir> (?idiotic parameter seem to be demanded only for executables, or not)

So how would it look like, with all the properly added quotes, to work with mentioned: Run, RunQ, Run Quote() ?
Sorry if you find this question dumb/stupid(just pass by). After recently spending again couple hours and not finding a working way, i've got quite angry. Yet i understood that it's easier to make an LNK file and open that, than use Run command.(which definitely doesn't look normal)
So i wanna finally understand the proper always working way to use Run variations for complex run requests with additional paths and parameters.

P.S. Please don't send me to lax(). I've found it via search along with lots of topics that didn't answer my goal-question. Have no clue what lax is, and even though it seems to do the work much easier -- i really want to settle the deal of problem with these 3 Run variations, not just find a code variant that works and settle down.(as most users did in search results)

Re: How to propely use Run, Runq, Run Quote() ?

Posted: 29 Jan 2025 14:59
by highend
The two outer double quotes are stripped and all inner ones per each part as well
run """<tool>"" ""arg1"" ""arg2"" ... ""last arg""";
First step:
run ""<tool>"" ""arg1"" ""arg2"" ... ""last arg"";
Last step:
run "<tool>" "arg1" "arg2" ... "last arg";

and yes, using lax is much easier^^
run lax("<tool>" "arg1" "arg2" ... "last arg");
Done...

And in general: Use step; before such a command to see how it will resolve...

Re: How to propely use Run, Runq, Run Quote() ?

Posted: 01 Feb 2025 23:10
by eil
highend wrote: 29 Jan 2025 14:59 And in general: Use step; before such a command to see how it will resolve...
Useful hint, thanks, usually have Step mode enabled but didn't ever insert per-command variant.
highend wrote: 29 Jan 2025 14:59 and yes, using lax is much easier^^
run lax("<tool>" "arg1" "arg2" ... "last arg");
I simply don't know what lax stands for and how it works, that's why didn't even notice it being added.
highend wrote: 29 Jan 2025 14:59 The two outer double quotes are stripped and all inner ones per each part as well
run """<tool>"" ""arg1"" ""arg2"" ... ""last arg""";
First step:
run ""<tool>"" ""arg1"" ""arg2"" ... ""last arg"";
Last step:
run "<tool>" "arg1" "arg2" ... "last arg";
That's actually an example why i made this question, cause this description is misleading: as i understood for now, only paths with spaces mandatory need own quotes, at the same time args don't need quotes(unless arg is a path, and even then only the path needs be quoted - not whole/each arg).

Plus, the thing with apostrophe sign( ' ) brings some turmoil when reading shared scripts, cause it's not really obvious that:

Code: Select all

"""<tool>"" ""<target>"" ""<result>"" arg1 arg2"
"'<tool>' '<target>' '<result>' arg1 arg2"
meant to work the same.

Runq and Run Quote() remain a mystery for me, as description made me think theses solely "add an extra quote wrap". So these variants should work the same, but again - nope:

Code: Select all

run """<tool>"" ""<target>"" ""<result>"" arg1 arg2";
runq ""<tool>"" ""<target>"" ""<result>"" arg1 arg2;
run quote(""<tool>"" ""<target>"" ""<result>"" arg1 arg2);

Re: How to properly use Run, Runq, Run Quote() ?

Posted: 02 Feb 2025 14:21
by highend
cause this description is misleading
It's not misleading, I'm just assuming that your args are strings that can have space(s), e.g. when using ffmpeg for doing stuff
If they actually contain spaces or not is irrelevant because you should always assume that they could have them
Especially when using variables
Ofc you do not need the quotes when no quoting is necessary^^

Code: Select all

run """C:\one space\app.exe"" ""D:\two  spaces\a.pdf"" --no-defaults --output=""E:\b.pdf""";
Never used runq nor single quotes for run (because variables aren't resolved inside single quotes)

One of the reasons why lax() is the command of choice is: an embedded call

Code: Select all

run lax("$hstart" /UAC ""$fileLocker" /k "<curitem>""), "%TEMP%", 0, 1;
Have fun doing that with the normal run command without lax()^^
This call is clean, logical and you don't need to wrap your mind around that...

There is one exception when you can't use lax(): You have non-quotable arguments that contain a ;...

Re: How to properly use Run, Runq, Run Quote() ?

Posted: 27 Feb 2025 01:00
by eil
highend wrote: 02 Feb 2025 14:21 Never used runq nor single quotes for run (because variables aren't resolved inside single quotes)
Didn't know that variable vs single quote thing. Damn hope won't forget it.

Still, can you please elaborate how lax works/what it does? Why it seem to solve those quoting problems easily while prior commands can't do same?