I wrote a simple c-program DOW.exe, the return value is the day of week. I need this for my batchfile, so how can i do this, how can i get the return value ?
DOW.exe: Tu
my batchfile (doesn't work):
set day = DOW.exe
echo = %day%
Use %ERRORLEVEL%
. Like echo %ERRORLEVEL
.
If, as seems, the dow.exe
file echoes to console (stdout from the program) the day of week as text, then:
From command line
for /f %a in ('dow.exe') do set "dow=%a"
For usage inside a batch file, percent signs need to be escaped
for /f %%a in ('dow.exe') do set "dow=%%a"
What it does is execute the indicated command, retrieve its output and for each line in it, execute the code after the do
clause, with the line retrieved stored inside the for
replaceable parameter (%%a
in this case)
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