Note that there are some explanatory texts on larger screens.

plurals
  1. POBatch script if else command
    primarykey
    data
    text
    <p>I'm trying to make a simple batch script to wipe/zero a flash drive and reformat it. It's for others, so i'm attempting to make it relatively safe, by blocking formatting to C:, D:, etc.</p> <p>I'm looking for an IF ELSE type command i can use, to be an error catch-all.</p> <p>Here's (the main portion of) what i have ATM</p> <pre><code>:again echo. cls echo. echo Please select the drive letter for the flash echo drive you wish to erase echo. echo **** DO NOT SELECT C: OR D: **** echo. echo. echo *** Enter letter (no colon) ONLY e.g. "E" *** echo. set /p answer= cls echo. echo. echo. if /i "%answer:~,1%" EQU "e" format E: /x /fs:FAT32 /v:FORENSICS /p:2 if /i "%answer:~,1%" EQU "f" format F: /x /fs:FAT32 /v:FORENSICS /p:2 if /i "%answer:~,1%" EQU "g" format G: /x /fs:FAT32 /v:FORENSICS /p:2 if /i "%answer:~,1%" EQU "h" format H: /x /fs:FAT32 /v:FORENSICS /p:2 if /i "%answer:~,1%" NOT exist goto again &amp;&amp; echo Please provide a valid drive letter for flash drive echo. </code></pre> <p>Now I know that </p> <pre><code>if /i "%answer:~,1%" NOT exist goto again &amp;&amp; echo Please provide a valid drive letter for flash drive </code></pre> <p>is not valid syntax, but what could I use in order to achieve the same goal? I know there is a more effecient way to do this (e.g. instead of defining 4 variables for likely drive letters, put a single variable that listens to user input and accepts it if it exists.)</p> <p>This is my first foray into batch scripting (and scripting in general) and i'm learning on-the-fly, so the "dumber" you can make it, the better.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload