The formal way to redirect stderr to stdout in a cmd script is to use the 2>&1 option before running the script:
e.g. MyScript.cmd > output.txt 2>&1
Is there a way to redirect stderr to stdout in a middle of running?
(Pushing my code to a main function and calling to it with 2>&1 isn't solution for me due to unwanted side effects)