6

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%

2 Answers 2

8

Use %ERRORLEVEL%. Like echo %ERRORLEVEL.

Sign up to request clarification or add additional context in comments.

1 Comment

that returns a number like 2686742
6

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)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.