When I try to get the output of a command in a batch file by using single quotes I am getting the following info:
C:>for /f "tokens=2 delims=:." %a in ('chcp') do (echo %a)
'chcp' is not recognized as an internal or external command, operable program or batch file.
This command can be run from the same location directly:
C:>chcp
Active code page: 437
I have already checked env variables and they seem to be set correctly. Above problem occurs also when I use 'dir' instead of 'chcp'.
Any ideas what can be the reason and how to fix that?
OS: WIN 10
C:\>where chcp C:\Windows\System32\chcp.com C:\Windows\SysWOW64\chcp.com
Seems like it's in a proper place. I was able to run this command directly from command like with no issues but for some reason it doesn't work from bat file. Also, my PATH includes C:\Windows\system32chcp
, thus probably a path issue, or something odd with theFor
construct.