Page 1 of 1

Read text from .txt file and keep to paramter

Posted: 2023-Dec-29, 1:03 pm
by WhoIam
Hi I'm new for this. But I need somebody help me or recommend.

I have file Result.txt. The value inside this file is text = "Lan card". I need a command .bat that will read the value from the .txt file and store the text value "Lan card" in the result variable and echo it. The results came out.

Re: Read text from .txt file and keep to paramter

Posted: 2024-Jan-01, 12:10 pm
by Hackoo
This batch script reads the content of the Result.txt file and stores it in the result variable. Then, it echoes the value of the result variable to the console.

Code: Select all

@echo off
setlocal
set "file=Result.txt"
for /f "usebackq delims=" %%a in ("%file%") do (
    set "result=%%a"
)
echo %result%
endlocal
pause