Is there any Windows equivalent syntax to run a command within another command in a bat script file?
In Linux, you can simply use $(...) or ``.
Yes, at least for simple things:
@setlocal enableextensions enabledelayedexpansion
@echo off
for /f %%w in ('echo xyzzy') do set var=%%w
echo Output is %var%
endlocal
The output of that script is:
Output is xyzzy
with the xyzzy
coming from the echo
command.
Running for /?
from a command window should give you a more comprehensive list of options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With