Read text from .txt file and keep to paramter

Microsoft Windows
Post Reply
WhoIam
Posts: 1
Joined: 2023-Dec-29, 12:57 pm

Read text from .txt file and keep to paramter

Post 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.
Hackoo
Posts: 5
Joined: 2021-Oct-17, 6:40 pm

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

Post 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
Post Reply