Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi there,
I was wondering is there a way to declare a variable in a batch file (WinNT) ??
Regards,
Brandon

yep.
SET VARIABLE=What you wanna set it to.
if you wanna retrieve it; refer to it as:
%VARIABLE%anyway, there's not much you can do with variables, however :)
oh, and don't forget how much environment space you have, you'll run out at some point and you wont be able to fit any more variables :)
- W0rm

There are many ways, depending on exactly what it is you want to do. The following example shows how to set a variable from data input from the keyboard (input data).
Some of these lines are long, and have wrapped. Everything you see above and below a blank line should be on a single line (you can delete the blank lines. I created this batch file with the name of INPUT.BAT.
*************************
@ECHO OFF
SET DATA=FC /LB1 /N CON NUL | TIME | FIND " 1: " > EN#ER.BAT
> ENTER.BAT ECHO SET DATA=%%4
CALL EN#ER.BAT
DEL EN?ER.BATInvoke this batch fle by typing "enter" at the dos prompt while in the directory that you created enter.bat in.
You can then type any word (only one) followed by the return key.
If you now type "set", DOS will display all of the environment variables. The "data" environment variable will contain the word you typed. I hope this helps.
This file can be modified to allow more than one word to be input. If you would like more information on this batch file, email me at cbruno3790@aol.com

I am looking for a way to have a batch file create a file name using the system date. For example if I want to use a batch file to retrieve backup information from many servers and store that info in one file. But I want to keep a history of those files and use the date to name them.. Anby help would be appreciated.

![]() |
install win95 from win3.1
|
trying to run dos games i...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |