Problem with ELSE.
Posted: 21 Jul 2020 17:30
Good evening,
I have this code . . .
What works OK:
[1] If I press <ENTER> instead of entering a drive letter it gives me the correct message . . .
[2] If I enter an incorrect drive letter it gives me the correct message . . .
[3] If I plugin a USB and it gets allocated drive letter G: for example, and I then run the code, it performs the chkdsk correctly and gives me the correct text after it has finished as shown in the code here . . .
What DOESN'T works OK:
If I enter C as the drive letter, it prompts me to either enter "Y" to perform chkdsk on the next reboot, or "N" to cancel the process. So far so good.
Regardless of whether I enter "Y" or "N" I want it to show this . . .
. . . and regardless of which I enter for it to . . .
I have spent hours on this and it is almost there.
Any help will be greatly appreciated.
Thanks in advance.
I have this code . . .
Code: Select all
set "Drive="
echo Which drive would you like to check for ERRORS?
set /p "Drive=>Please enter the drive letter and press <Enter>: "
if not exist %volume% %Drive%:\ (
echo ERROR: The drive does NOT exist^^!
echo ^>Press ANY key to return to the Options . . . & pause >nul
cls & goto :Options
) else (
if "%Drive%"=="C" (
chkdsk %Drive%: /F
echo press ^<ENTER^> to return to the Options.
echo press ^<Y^> and ^<ENTER^>.
goto :REBOOT_Choice
) else (
chkdsk %Drive%: /F
Please thoroughly check the results above
echo ^>Press ANY key to return to the Options . . . & pause >nul
cls & goto :Options
)
)
[1] If I press <ENTER> instead of entering a drive letter it gives me the correct message . . .
Code: Select all
echo ERROR: The drive does NOT exist^^!
Code: Select all
echo ERROR: The drive does NOT exist^^!
Code: Select all
Please thoroughly check the results above
echo ^>Press ANY key to return to the Options . . . & pause >nul
cls & goto :Options
If I enter C as the drive letter, it prompts me to either enter "Y" to perform chkdsk on the next reboot, or "N" to cancel the process. So far so good.
Code: Select all
if "%Drive%"=="C"
Code: Select all
echo press ^<ENTER^> to return to the Options.
echo press ^<Y^> and ^<ENTER^>.
Code: Select all
goto :REBOOT_Choice
Any help will be greatly appreciated.
Thanks in advance.