set /p Select=Enter y: Not working
Posted: 09 Feb 2021 18:03
I created this bat script to fix a computer that won't boot. It needs the ESP partition fixed so I can make it bootable.
I'm having trouble with one SET statement that isn't doing what I want it to do. I can't figure out why.
Towards the end of the code you will see:
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
:: When I enter a lower case y it goes to :eof. I want it to continue with the bat file.
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
That's where the problem is.
Please help me fix it.
Thank you,
Docfxit
I'm having trouble with one SET statement that isn't doing what I want it to do. I can't figure out why.
Towards the end of the code you will see:
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
:: When I enter a lower case y it goes to :eof. I want it to continue with the bat file.
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
That's where the problem is.
Please help me fix it.
Thank you,
Docfxit
Code: Select all
@echo on
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
:: Warning!!!
:: Do not run this on your computer. It is customized for my computer.
:: Your computer will probably be different.
:: ************** This could cause harm to your computer. ***********
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
:: 1. Boot from your bootable medium
:: Make sure that you are booting in UEFI mode
:: 2. At the first screen (where it asks you to choose language and keyboard),
:: press Shift + F10. This will give you a command prompt.
echo > USBMakeBootable.scr list disk
echo >>USBMakeBootable.scr exit
diskpart /s USBMakeBootable.scr
set /p Disk=Please enter the disk number:
if "%Disk%"=="" goto :eof
echo >USBMakeBootable.scr Select disk %Disk%
echo >> USBMakeBootable.scr list partition
echo >>USBMakeBootable.scr exit
diskpart /s USBMakeBootable.scr
set /p Partition=Please enter the system partition number:
:: make sure that there is a partition of type system (the efi partition).
if "%Partition%"=="" goto :eof
echo >USBMakeBootable.scr Select disk %Disk%
echo >>USBMakeBootable.scr Select partition %Partition%
echo >>USBMakeBootable.scr assign letter=G
echo >>USBMakeBootable.scr list vol
echo >>USBMakeBootable.scr exit
diskpart /s USBMakeBootable.scr
@Echo Off
Echo "You should see a volume with drive letter (Ltr) as G"
Echo "file system (Fs) as FAT32"
Echo .
set /p Select=Enter y:
if "%Select%"=="y" (
ECHO Yes
) ELSE (
echo >USBMakeBootable.scr Select disk %Disk%
echo >>USBMakeBootable.scr Select partition %Partition%
echo >>USBMakeBootable.scr list vol
echo >>USBMakeBootable.scr exit
diskpart /s USBMakeBootable.scr
Echo "You should see a volume with drive letter (Ltr) as G"
Echo "file system (Fs) as FAT32"
Echo .
set /p Select=Enter y:
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
:: When I enter a lower case y it goes to :eof. I want it to continue with the bat file.
:: *~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
if /I "%Select%"=="y" (
ECHO Yes
) ELSE (
goto :eof
)
)
echo >USBMakeBootable.scr Select disk %Disk%
echo >>USBMakeBootable.scr Select partition %Partition%
echo >>USBMakeBootable.scr detail partition
echo >>USBMakeBootable.scr exit
diskpart /s USBMakeBootable.scr
Echo "Is drive letter (Ltr) G (Info) Hidden?"
Echo .
set /p Select=Enter y:
if "%Select%"=="y" (
echo >USBMakeBootable.scr Select disk %Disk%
echo >>USBMakeBootable.scr Select partition %Partition%
echo >>USBMakeBootable.scr set id = 07 override
echo >>USBMakeBootable.scr detail partition
echo >>USBMakeBootable.scr exit
diskpart /s USBMakeBootable.scr
)
GoTo :Skip
echo >>USBMakeBootable.scr clean
echo >>USBMakeBootable.scr create part pri
echo >>USBMakeBootable.scr select part 1
echo >>USBMakeBootable.scr format fs=ntfs quick
echo >>USBMakeBootable.scr active
echo >>USBMakeBootable.scr exit
echo diskpart /s USBMakeBootable.scr
:Skip
:eof
del USBMakeBootable.scr
cmd /k