Solved

How Do You Create Variables In A Batch Program?

Posted on 2006-06-09
2
286 Views
Last Modified: 2012-05-05
Before I get into this question, I thought I'd take a second to let everyone know how powerful a batch program can be. If you really think hard about it, you can solve a lot of your problems by creating batch programs. I just recently created a backup utility that back-up's my entire slew of documents including favorites and pictures, what a reality check. Yes, instead of going to some website and shelling $30 for some hi-tech backup utility, I made my own, pretty handy, I have to say. Just wanted to get that out of my system... so on to the question.

How can I create my own variables in my batch files and use them? What can I type (command) to have someone input into that variable a string... or basically how can I get the user to input something into my variable, so I can then play with it? Big points for this one. I would like to know.

Nicolae Crisan
HandyTech, DBA
0
Comment
Question by:ncwhiz
2 Comments
 
LVL 10

Accepted Solution

by:
GuruGary earned 215 total points
ID: 16875623
Yes, batch programming is much more powerful than most people think.  Especially in Windows 2000, Windows XP and higher.

You can use the SET command with the /P switch.  Try this:

@echo off
set /p Name=Please enter your name:
echo Thank you, %Name%
0
 
LVL 1

Author Comment

by:ncwhiz
ID: 16875768
Hi Gary,
Sent you an email "Batch Programming, Question" and I will award you the points, because I got the right answer. THANKS!

Nicolae
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question