How to set commands output as a variable in a batch file

前端 未结 9 1266
我在风中等你
我在风中等你 2020-11-22 01:19

Is it possible to set a statement\'s output of a batch file to a variable, for example:

findstr testing > %VARIABLE%

echo %VARIABLE%
9条回答
  •  你的背包
    2020-11-22 01:54

    To read a file...

    set /P Variable=

    To Write a file

    @echo %DataToWrite%>File.txt
    

    note; having spaces before the <> character causes a space to be added at the end of the variable, also

    To add to a file,like a logger program, First make a file with a single enter key in it called e.txt

    set /P Data=log0.txt
    

    your log will look like this

    Entry1
    Entry2 
    

    and so on

    Anyways a couple useful things

提交回复
热议问题