0

I have a batch file that uses the for command to parse the output from another command, but I want all errors written to STDERR to be suppressed.

I have tried this:

for /F "usebackq delims=" %%a in (`mycommand.exe 2>nul`) do set RESULT=%%a

in which I'm attempting to redirect STDERR to nul for the inner embedded command, but I get this error:

2> was unexpected at this time.

How can I ignore all errors generated by mycommand.exe?

1

Solution

The redirection operator must be escaped:

for /F "usebackq delims=" %%a in (`mycommand.exe 2^>nul`) do set RESULT=%%a

Further reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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