Returns the value from batch files (.bat file) to a text file

I have a .bat file shown below

@echo off 
for /f "delims=" %%a in ('C:\MyProj\Sources\SearchString.vbs') do (
set ScriptOut=%%a)
#echo Script Result = %ScriptOut%
echo %ScriptOut% >C:\ThreePartition\Sources\myfile.txt

I want my output variable that ScriptOut stored in a text file. Can anyone suggest any method to add to my existing batch file.

Thanks Maddy

+3
source share
2 answers

Do I understand correctly that your file is overwritten and you want to add it? If yes, try the following:

echo %ScriptOut% >> C:\ThreePartition\Sources\myfile.txt

(note the double "→")

+2
source

for, , script , script. , %ScriptOut% ( , ). , script

a
b
c

%ScriptOut% c. , iot %ScriptOut%, ,

echo %ScriptOut%

ECHO is on., , , echo.

-.% ScriptOut%

( %ScriptOut% .

, script , ,

cscript C:\MyProj\Sources\SearchString.vbs > C:\ThreePartition\Sources\myfile.txt

>> , , , .

, :

for /f "delims=" %%a in ('C:\MyProj\Sources\SearchString.vbs') do (
  if not "%%a"=="" set ScriptOut=%%a
)

%ScriptOut%, .

+2

Source: https://habr.com/ru/post/1706228/


All Articles