Solved

How Do You Create Variables In A Batch Program?

Posted on 2006-06-09
2
276 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
changePi Challenge 15 104
mapBully challenge 6 114
Arduino EDI - Programming Language - Voice Recorder 4 69
iSeries email authority 4 25
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
A short article about a problem I had getting the GPS LocationListener working.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now