Reading a specific line in a text file to a variable in a batch file -


in 1 of batch files i'm attempting write, need read last line in 5 line text file variable. 1 way thought of doing might have each line put text file overwrite previous (as files creation , lines created command, slmgr /xpr) i'm not sure how this. suggestions or alternate ways of doing appreciated!

cscript %windir%\system32\slmgr.vbs /xpr > xprtest.txt pause /f "skip=4 delims=" %i in (xprtest.txt) set /p xprvar= <xprtest.txt pause echo %xprvar% 

if want line 5:

set "xprvar=" /f "skip=4 delims=" %%i in (xprtest.txt) if not defined xprvar set "xprvar=%%i" 

or

for /f "skip=4 delims=" %%i in (xprtest.txt) set "xprvar=%%i"&goto nextline :nextline 

if want last line regardless of number of lines:

for /f "delims=" %%i in (xprtest.txt) set "xprvar=%%i" 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -