Results 1 to 4 of 4

Thread: User inputs in Batch (.bat) files

  1. #1
    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?

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    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.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    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.

  4. #4
    Join Date
    May 2008
    Posts
    2,012

    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!

Similar Threads

  1. Batch file : How to create folders with user input
    By BLaaR in forum Software Development
    Replies: 1
    Last Post: 10-05-2012, 06:53 PM
  2. Need batch file to delete user files in Windows XP
    By mcamp32 in forum Windows XP Support
    Replies: 1
    Last Post: 26-05-2011, 10:54 PM
  3. display all the odd numbers between the range the user inputs
    By MaryJ in forum Software Development
    Replies: 1
    Last Post: 22-11-2010, 05:13 PM
  4. Replies: 1
    Last Post: 20-11-2010, 07:07 PM
  5. How to add local domain user via batch file
    By Imtiyaz in forum Networking & Security
    Replies: 3
    Last Post: 18-05-2009, 09:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,539,041.20603 seconds with 17 queries