1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Batch file help.

Discussion in 'DOS/Other' started by jstanley823, Feb 18, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. jstanley823

    jstanley823 Thread Starter

    Joined:
    Feb 18, 2013
    Messages:
    2
    hi im trying to make a batch file where the user is prompted to select a drive. how do i write it in a batch where the user can select any drive and it will show that drives space.
     
  2. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    WMIC LOGICALDISK GET Name,Size,FreeSpace
     
  3. jstanley823

    jstanley823 Thread Starter

    Joined:
    Feb 18, 2013
    Messages:
    2
    thanks.. that is what I am looking for but I was trying to make it like

    @echo off
    echo userinputpath=please select a drive
    then from here what ever drive they use as input will show the free space for that drive.
     
  4. Chained

    Chained

    Joined:
    Feb 19, 2013
    Messages:
    3
    You can use the choice command but that requires you to list all the variables. If you want unlimited variables I recommend using:

    set /p Input=Please select a drive letter:
    :: Test to display the output:
    echo %Input

    the downside of using this is that they can literally put in anything and obviously, if they type "help" for example, this could cause your script to fail or worse yet do something it's not meant to. If you have a limited number of options I recommend the choice command:

    choice /c acefy /m "Please pick the drive to use, A, C, E, F, or Y."
    if errorlevel 1 set drive=A
    if errorlevel 2 set drive=C
    if errorlevel 3 set drive=E
    if errorlevel 4 set drive=F
    if errorlevel 5 set drive=Y
    :: Test to display the output:
    echo %drive%
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1090108

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice