Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? tokens and delims problem

Nov
33
0
Hi guys, this is my CMD batch:

FOR /F tokens^=5^ delims^=\^" %%G IN ('REG QUERY "HKCR\http\shell\open\command" /v ""') DO SET Default=%%G

It works perfectly, but once compiled with Take Command (.btm file), my scripts doesn't work anymore... Have you an idea to correct it? Thanks in advance.
 
I never use that syntax myself, but isn't the whole TOKENS and DELIMS business supposed to go in double quotes?
 
T
I never use that syntax myself, but isn't the whole TOKENS and DELIMS business supposed to go in double quotes?
That's correct, and documented. But with the documented syntax, you can't use a double-quote as a delimiter. So the OP used the kludge (find it on stackoverflow or superuser)
Code:
tokens^=5^ delims^=\^"
which is considered a single argument (as if it were quoted) because all the normal argument separators have been escaped.

I doubt Rex will feel compelled to emulate that behavior. In TCC, do it like this:
Code:
v:\> FOR /F "tokens=5 delims=\^q" %G IN ('REG QUERY "HKCR\http\shell\open\command" /v ""') DO echo %G
command
 -osint -url
... which is correct ... double the quotes on the variable G if you like.
 
Here's a nice way to do it with TCC.
Code:
v:\> echo %@word["\^q",3,%@regquery[HKCR\http\shell\open\command\]]
 -osint -url
(which is correct).
Notice how brief and to-the-point it is ... and that running the external REG.EXE is not necessary.
 
It's perfect, thank you very much vefatica! :happy:
You're welcome. You can get rid of the leading and trailing spaces like this:
Code:
v:\> echo %@trim[%@word["\^q",3,%@regquery[HKCR\http\shell\open\command\]]]
-osint -url
 
What's the goal? To get the filename of the default web browser?

You can get the default open string with:
Code:
echo %@ftype[http]

To grab the first word of that string:
Code:
echo %@word[0,%@ftype[http]]

And to strip off the path and get just the filename:
Code:
echo %@filename[%@word[0,%@ftype[http]]]
 
Yup! @FTYPE is a little easier than @REGQUERY.
Code:
v:\> echo %@ftype[http]
"l:\Firefox\firefox.exe" -osint -url ""
Once you have that string, you can extract from it whatever information you want. A few examples have been given.
 

Similar threads

Back
Top