In Linux (Bash), there's a way to use a command as a parameter for another command, using back-ticks:

> echo ===== `time` =====

This would print:

===== The current time is: 12:22:34.68 =====

Is there a way to do this in cmd.exe on WIndows ?

link|improve this question

80% accept rate
1  
see this post – Prince John Wesley May 27 '11 at 9:38
2  
Also see this this post (use of doskey command from cmd) – misterjaytee May 27 '11 at 11:00
@misterjaytee: Command substitution and aliases are different things. – grawity May 27 '11 at 13:59
@grawity - Thanks for pointing that out - Note to self: must read the question properly before responding... – misterjaytee May 30 '11 at 13:26
show 3 more comments
feedback

1 Answer

up vote 1 down vote accepted

Try this:

echo. ===== %time% =====

I know this may not be what you want, because you mentioned command substitution... So this may be it:

for /f "usebackq tokens=*" %i in (`date/t&time/t`) do echo.  ===== %i =====

For more hints about the usage of usebackq try this command:

for /?
link|improve this answer
Yep, for /f is what I was looking for. Thanks! On a side note: It's so kludgy and hard to remember (compared to the bash way). I should give up "bat programming" and learn something more productive - PowerShell maybe? – Cristi Diaconescu Jul 7 '11 at 20:10
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.