Solved How do i Save/Load Batch Variables From a text file?

July 22, 2012 at 23:43:57
Specs: Windows Vista
How do i Save/Load Batch Variables From a text file or any other file?
is this possible?
and if so how do i do this??

See More: How do i Save/Load Batch Variables From a text file?

Report •


#1
July 23, 2012 at 00:47:08
✔ Best Answer
If your file looks like:

x=abc
z=qwerty

:: ===== script starts here ===============
::
:: vfromt.bat 2012-07-23 14:45:04.17
@echo off > newfile & setLocal enableDELAYedeXpansioN

for /f "tokens=* delims= " %%a in (my.txt) do (
set %%a
)
set
goto :eof

::====== script ends here =================


====================================
Life is too important to be taken seriously.

M2


Report •

#2
July 23, 2012 at 16:18:45
Can you explain how this works clearly please?, i still dont understand.
also, is it possible to load commands from a text file?

Report •

#3
July 24, 2012 at 07:05:06
the contents of my.txt

x=abc
z=qwerty

using the script above "vfromt.bat" (from Mechanix2Go)
It loops through my.txt and pulls the lines in to be stored in %%a
then each time it pulls said line it uses the set %%a to assign a variable

so for example the

::first time through it changes
set %%a to set x=abc
::then the second loop
set %%a to set z=qwerty

You could technically do this with any command I suppose.

:: mike


Report •

Related Solutions

#4
July 24, 2012 at 22:32:42
cool thanks

Report •


Ask Question