-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathburnToFlash.bat
More file actions
64 lines (51 loc) · 1.72 KB
/
burnToFlash.bat
File metadata and controls
64 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@echo off
setlocal enabledelayedexpansion
:: Check if we already stored the script dir
if not exist "C:\PBFT\temp.txt" (
REM Store script directory before elevating
set "currentDir=%~dp0"
set "currentDir=%currentDir:~0,-1%"
mkdir C:\PBFT >nul 2>&1
REM echo %currentDir% > C:\PBFT\temp.txt
(
echo %~dp0
) > C:\PBFT\temp.txt
REM Relaunch with admin rights
echo Requesting admin privileges...
powershell -Command "Start-Process '%~f0' -Verb runAs"
exit /b
)
:: We're now elevated. I guess... if the previous usage hasn't failed. Anyways... Load the previously stored script directory
set /p ScriptDir=<C:\PBFT\temp.txt
:: Print the disclaimer (VERY IMPORTANT, READ IT CAREFULLY MULTPILE TIMES!!!!!!)
echo DOUBLE- AND TRIPLE-CHECK WHAT YOU HAVE INPUTED! THE SCRIPT MAKES ABSOLUTELY ZERO CHECKS AND INPUTING INCORRECT DATA WILL RESULT IN A DATA LOSS!!! YOU'VE BEEN WARNED.
:: Show available disks
(echo list disk
echo exit
) | diskpart
echo Select your FLASH DRIVE's disk number.
echo ALL FILES ON THAT DRIVE WILL BE DELETED.
:DiskInput
set /p PN=Enter the disk number:
echo %PN% | findstr /r "^[0-9][0-9]*$"
:LetterInput
set /p PL=Enter a free partition letter (without ":"):
echo %PL% | findstr /r "^[a-zA-Z]$"
:: Diskpart: the scariest shit. I feel with my ass that I will lose data due to -t-h-i-s--s-c-r-i-p-t- my mistake sometime in the future...
(
echo select disk %PN%
echo clean
echo create partition primary
echo select partition 1
echo format fs=fat32 quick
echo assign letter=%PL%:
echo exit
) | diskpart
:: Copy files
robocopy "%ScriptDir%\image" "%PL%:" /E /COPYALL /R:0 /W:0
:: Clean up
echo Cleaning up...
del C:\PBFT\temp.txt >nul
rmdir C:\PBFT >nul
pause
exit