Computing.Net > Forums > Disk Operating System > Is there any ways to declare a variable inside a batch file ??

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Is there any ways to declare a variable inside a batch file ??

Reply to Message Icon

Name: Brandon
Date: July 6, 2000 at 19:21:55 Pacific
Comment:

Hi there,

I was wondering is there a way to declare a variable in a batch file (WinNT) ??

Regards,
Brandon



Sponsored Link
Ads by Google

Response Number 1
Name: W0rm
Date: July 6, 2000 at 20:32:07 Pacific
Reply:

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


0

Response Number 2
Name: Laurence
Date: July 8, 2000 at 23:58:21 Pacific
Reply:

Not much you can do with variables??
Speak for yourself, man!!


0

Response Number 3
Name: Chuck Bruno
Date: July 13, 2000 at 08:48:05 Pacific
Reply:

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.BAT

Invoke 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


0

Response Number 4
Name: Steve
Date: July 17, 2000 at 09:41:34 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


install win95 from win3.1 trying to run dos games i...



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Is there any ways to declare a variable inside a batch file ??

is there any way to create a Splash Screen from within a batch file??? www.computing.net/answers/dos/is-there-any-way-to-create-a-splash-screen-from-within-a-batch-file/2547.html

ANY way to add an ext keyboard to a www.computing.net/answers/dos/any-way-to-add-an-ext-keyboard-to-a/13894.html

Can dos be run entirely from a cd-rom www.computing.net/answers/dos/can-dos-be-run-entirely-from-a-cdrom/11227.html