Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



User inputs in Batch (.bat) files

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 21-05-2009
Member
 
Join Date: Oct 2008
Posts: 35
User inputs in Batch (.bat) files
  

I wanted to know how we can create a batch file with user inputs in it. How does they work? I have seen my senior working on it, creating batch files with user inputs and then making installation of OS easier by which the bootable floppy disk would ask for the user input before the installation, then creates an answer file of the details inputted and then starts the installation, I want to try such a task and similar other things. Can I learn it easily?

Reply With Quote
  #2  
Old 21-05-2009
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: User inputs in Batch (.bat) files

Sometimes we need some user interaction in our batch files. We may need to know to which directory a file is to be copied, for example.
Or which drive needs to be formated.

There are many ways to achieve this user interaction.

The most basic form of user interaction, of course, is the PAUSE command, which halts the batch file until the user presses "any key" (apart from Ctrl, Alt, Shift, CapsLock, NumLock or ScrollLock).

Maybe not really sophisticated, but it works and is always available, in all DOS, Windows and OS/2 versions.
Reply With Quote
  #3  
Old 21-05-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: User inputs in Batch (.bat) files

If you want the user to choose one of three options, you make a simple menu, then make three batch files whose names correspond to the menu choices:
Code:
@echo off 
echo Please pick a number and hit Enter: 
echo 1 - John
echo 2 - Ron 
echo 3 - Shawn
After the above batch file runs, the user is dropped back to a DOS prompt. All you'd have to do is create three more batch files ( 1.bat, 2.bat, and 3.bat ) which would launch the appropriate programs.
Reply With Quote
  #4  
Old 21-05-2009
Member
 
Join Date: May 2008
Posts: 2,007
Re: User inputs in Batch (.bat) files

Batch is usually used for computing without user interaction. All data are in files|DB|cmd line. Here is an example:

Create the following script and call it clientdir.cmd:
Code:
C:
CD \Clients
SET /P cname=[Enter Last Name]
MKDIR %cname%
CD %cname%
MKDIR subdir1
MKDIR subdir2
You can set up a shortcut to clientdir.cmd. Enjoy!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "User inputs in Batch (.bat) files"
Thread Thread Starter Forum Replies Last Post
Batch file : How to create folders with user input BLaaR Software Development 1 10-05-2012 07:53 PM
Need batch file to delete user files in Windows XP mcamp32 Windows XP Support 1 26-05-2011 11:54 PM
display all the odd numbers between the range the user inputs MaryJ Software Development 1 22-11-2010 05:13 PM
calculate the sum of all the even numbers between the range the user inputs MaryJ Software Development 1 20-11-2010 07:07 PM
How to add local domain user via batch file Imtiyaz Networking & Security 3 18-05-2009 10:51 PM


All times are GMT +5.5. The time now is 02:02 AM.