Solved

How Do You Create Variables In A Batch Program?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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…

759 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

23 Experts available now in Live!

Get 1:1 Help Now