Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit b64fe0e

Browse files
authored
2a
2a
1 parent 9c21ea2 commit b64fe0e

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

main.bat

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,86 @@
22
::FEEL FREE TO USE PARTS OF THE CODE, IF YOU DO IT WOULD BE NICE TO GIVE CREDITS TO ME AND THIS REPO :)
33
::startup stuff
44
@echo off
5-
title Extendify alpha 1c by revox
5+
title Extendify alpha 2a by revox
66
cd %~dp0
77
setlocal EnableDelayedExpansion
8+
set drivelbl=New drive
9+
set driveltr=A:
810
cd resources
911
for /f "usebackq delims=" %%a in ("options.ini") do set %%a
1012
if %legacy-colors% == 0 color F0
1113
if %debug% == 1 echo DEBUG: set startup options
1214
if %debug% == 1 echo DEBUG: loaded options file
13-
goto drivescr
15+
goto selectscr
16+
17+
:selectscr
18+
cls
19+
echo What do you want to do?
20+
if %debug% == 1 echo DEBUG: awaiting input
21+
cmdMenuSel F08F "Extend capacity of a removable drive" "Restore original capacity of a removable drive"
22+
if %ERRORLEVEL% == 1 goto drivescr
23+
if %ERRORLEVEL% == 2 goto restorescr
24+
goto selectscr
25+
26+
:restorescr
27+
cls
28+
echo Select the drive you want to restore capacity
29+
echo Available drives:
30+
::use wmic to get available drives and save them to a file:
31+
for /f "tokens=2 delims==" %%d in ('wmic logicaldisk get name /format:value') do echo %%d >drives.ini
32+
if %debug% == 1 echo DEBUG: wmic got disk list
33+
::parse values from the file:
34+
set/p array=< drives.ini
35+
set a=%array:~0,5%
36+
set b=%array:~2,2%
37+
set c=%array:~5,2%
38+
set d=%array:~7,2%
39+
set e=%array:~9,2%
40+
set f=%array:~11,2%
41+
if %debug% == 1 echo DEBUG: array generated
42+
del drives.ini
43+
if %debug% == 1 echo DEBUG: temp file deleted
44+
::create a selection screen using previously saved sets:
45+
if %debug% == 1 echo DEBUG: awaiting input
46+
cmdMenuSel F08F "%a%" "%b%" "%c%" "%d%" "%e%" "%f%"
47+
if %ERRORLEVEL% == 1 set driveltr=%a%
48+
if %ERRORLEVEL% == 2 set driveltr=%b%
49+
if %ERRORLEVEL% == 3 set driveltr=%c%
50+
if %ERRORLEVEL% == 4 set driveltr=%d%
51+
if %ERRORLEVEL% == 5 set driveltr=%e%
52+
if %ERRORLEVEL% == 6 set driveltr=%f%
53+
goto confirmrestore
54+
55+
:confirmrestore
56+
cls
57+
echo You have selected drive %driveltr%
58+
echo The drive will be reset to its orignal capacity
59+
echo Be aware that this process will erase all data (format it)!
60+
echo Continue?
61+
if %debug% == 1 echo DEBUG: awaiting input
62+
cmdMenuSel F08F "Yes" "No"
63+
if %ERRORLEVEL% == 1 goto restore
64+
if %ERRORLEVEL% == 2 goto restorescr
65+
goto confirmrestore
66+
67+
:restore
68+
cls
69+
echo Please wait...
70+
timeout 1 >nul
71+
::we use mkdosfs windows port to format the drive which will then use its original capacity
72+
mkdosfs -n "%drivelbl%" -v %driveltr%
73+
goto restorefinishscr
74+
75+
:restorefinishscr
76+
cls
77+
echo The drive has been successfully restored to its original capacity
78+
echo What do you want to do next?
79+
if %debug% == 1 echo DEBUG: awaiting input
80+
cmdMenuSel F08F "Go back to main menu" "Exit program"
81+
if %ERRORLEVEL% == 1 goto selectscr
82+
if %ERRORLEVEL% == 2 exit
83+
goto restorefinishscr
84+
1485

1586
:drivescr
1687
cls

0 commit comments

Comments
 (0)