Saved Bookmarks
| 1. |
Solve : Need to set variable from a file? |
|
Answer» Hi, Hi, Well, the simple way would be to have a "prototype" file that contains: SET VAR_NAME= stored on the disk. NOTE that a return character should NOT follow the statement in the file. Given that, the command: copy pro.txt+data.txt temp.bat ... will create a set command to do the trick. Now, let's put it all together, assuming pro.txt contains the above set prototype, and data.txt contains your environment data. @echo off copy pro.txt+data.txt temp.bat call temp.bat del temp.bat ... other batch commands ... This will set the envronment variable and kill the temp batch file created to do the job. the user needs to input an unknown variable to be used later in the batch file. It cannot be a pre-determined variable.Where does the unknown variable come from? You said it was in a file, that's where I got the variable from. If you want the environment variable name to be fetched from a file, expand the same technique. If that's not it, define the problem more CLEARLY. I would like to run a batch file asking the user to input a 4-digit CODE. THat code (variable) will be used later in that batch file to create a directory.Randy, you should start your own thread, it's very confusing to have multiple questions in one thread. The idea is really smart. UNFORTUNATELY, the temp.bat script does not work because "copy pro.txt+data.txt temp.bat" makes temp.bat two lines. DOS can not explain it correctly. It might be better to start your own thread. Give as much information as possible: OS, what your trying to ACCOMPLISH etc. This thread is over two years old! 8-) |
|