Text File Cannot read by Batch File

Posted by Typowarrior on Server Fault See other posts from Server Fault or by Typowarrior
Published on 2012-10-04T03:24:07Z Indexed on 2012/10/04 3:39 UTC
Read the original article Hit count: 185

Filed under:

I have the problem where TXT file that batch create can't be read. it turns to ECHO OFF Result.

Here is 1st code need to be run.

echo.

wmic /output:huhu.txt Path CIM_DataFile WHERE Name='C:\\Users\\uJaNbaTus\\Desktop\\HyperTerminal.exe' Get Version

echo.

Then I create another .bat file with this code and run it.

echo.

setlocal ENABLEDELAYEDEXPANSION

set revision=
for /f "delims=" %%a in (huhu.txt) do (
    set line=%%a
     if "x!line:~0,8!"=="xVersion " (
        set revision=!line:~8!
    )
)
echo !revision!

echo.

endlocal

When I run this .bat file the result Showing ECHO off. Btw if I create another file using notepad and replace (huhu.txt) I didn't get any error and the output come from txt file.

© Server Fault or respective owner

Related posts about batch