Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Batch File Question

  • 03-10-2009 04:06AM
    #1
    Registered Users, Registered Users 2 Posts: 8,492 ✭✭✭


    How can I get a Batch file to prompt the user to enter the desired drive letter (For a backup location) ?

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



Comments

  • Closed Accounts Posts: 6,151 ✭✭✭Thomas_S_Hunterson


    The "CHOICE" (think it was CHOICE.COM) command can prompt a user to enter a letter. It then stores the index of the letter (i.e. it's position in the list) in the ERRORLEVEL enviroment variable.

    I think it was removed in windows XP. I just checked my vista machine and it's on it but that could have been because I downloaded it, I'm not sure. You can download it and just distribute it with the batch file or stick it in your system32 folder.

    You'd then have to go through a ream of IF commands.

    I'm sure there's an easier way to do it, but it's been years since if used batch files.


  • Registered Users, Registered Users 2 Posts: 8,492 ✭✭✭Gadgetman496


    Thanks for the reply.

    I'm trying to avoid having to distribute anything else with the Batch file if possible.

    I'm sure too that it can be done from within the batch file but it's been years since I worked on them & I'm afraid the light bulbs are very dim :rolleyes:

    -

    "Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid."



  • Registered Users, Registered Users 2 Posts: 386 ✭✭Zirconia
    Boycott Israeli Goods & Services


    You can use SET /P

    Look it up from the command prompt; SET /?

    for example:

    @echo off
    set /P DRIVE="Enter Drive Letter: "
    echo.
    echo You selected the %DRIVE% drive!
    echo.
    dir %DRIVE%:\
    pause


Advertisement