[crypto-block]
@ECHO OFF&PUSHD %~DP0 &TITLE Win32Loader
setlocal enabledelayedexpansion
::Author MoeClub.org
color 87
cd.>%windir%\GetAdmin
if exist %windir%\GetAdmin (del /f /q "%windir%\GetAdmin") else (
echo CreateObject^("Shell.Application"^).ShellExecute "%~s0", "%*", "", "runas", 1 >> "%temp%\Admin.vbs"
"%temp%\Admin.vbs"
del /s /q "%temp%\Admin.vbs"
exit /b 2)
cls
echo * Init Win32Loader.
set URL=https://moeclub.org/attachment/WindowsSoftware
set download=0
set try_download=1
:Init
mkdir "%SystemDrive%\win32-loader" >NUL 2>NUL
if exist "%SystemDrive%\Windows\System32\WindowsPowerShell" (
set use_ps=1
) else (
set use_ps=0
)
if %use_ps% equ 1 (
goto InitIt
) else (
goto InitFail
)
:InitIt
set try_download=0
powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/g2ldr','%SystemDrive%\g2ldr')}" >NUL 2>NUL
powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/g2ldr.mbr','%SystemDrive%\g2ldr.mbr')}" >NUL 2>NUL
powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!URL!/g2ldr/grub.cfg','%SystemDrive%\win32-loader\grub.cfg')}" >NUL 2>NUL
goto InitDone
:InitFail
echo Not found powershell, please download them by yourself.
echo '%SystemDrive%\g2ldr'
echo '%SystemDrive%\g2ldr.mbr'
echo '%SystemDrive%\win32-loader\grub.cfg'
echo Press [ENTER] when you finished.
pause >NUL 2>NUL
goto InitDone
:InitDone
if !try_download! equ 0 (
set InitOption=InitFail
) else (
set InitOption=Init
)
if not exist "%SystemDrive%\g2ldr" goto !InitOption!
if not exist "%SystemDrive%\g2ldr.mbr" goto !InitOption!
if not exist "%SystemDrive%\win32-loader\grub.cfg" goto !InitOption!
:Image
echo.
echo * Please select initrd mode.
echo [1] Online download
echo [2] Local file
choice /n /c 12 /m Select:
if errorlevel 2 goto LocalMode
if errorlevel 1 goto OnlineMode
goto Image
:OnlineMode
echo.
echo * Please select source.
echo [1] by MoeClub (DHCP or VNC Support)
echo [2] by yourself
choice /n /c 12 /m Select:
if errorlevel 2 goto Yourself
if errorlevel 1 goto MoeClub
goto OnlineMode
:Yourself
echo.
echo if 'initrd.img' URL is 'https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie/initrd.img', Please input 'https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie'.
set /p IMG_URL=URL :
if defined IMG_URL (
goto Download
) else (
goto MoeClub
)
:MoeClub
set IMG_URL=https://moeclub.org/onedrive/IMAGE/Loader/DebianJessie
goto Download
:Download
if %use_ps% equ 1 (
echo.
echo Downloading 'initrd.img'...
powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!IMG_URL!/initrd.img','%SystemDrive%\win32-loader\initrd.img')}" >NUL 2>NUL
echo Downloading 'vmlinuz'...
powershell.exe -command "& {$client = new-object System.Net.WebClient; $client.DownloadFile('!IMG_URL!/vmlinuz','%SystemDrive%\win32-loader\vmlinuz')}" >NUL 2>NUL
set download=1
) else (
echo Not support online download, auto change Local initrd.
goto LocalMode
)
:LocalMode
if !download! equ 0 (
echo.
echo Please put 'initrd.img' and 'vmlinuz' to '%SystemDrive%\win32-loader' .
echo Press [ENTER] when you finished.
pause >NUL 2>NUL
)
:Done0
set download=0
if exist "%SystemDrive%\win32-loader\initrd.img" (
goto Done1
) else (
echo Not found '%SystemDrive%\win32-loader\initrd.img' .
goto LocalMode
)
:Done1
set download=0
if exist "%SystemDrive%\win32-loader\vmlinuz" (
goto Done
) else (
echo Not found '%SystemDrive%\win32-loader\vmlinuz' .
goto LocalMode
)
:Done
echo.
echo Press [ENTER] to reboot...
pause >NUL 2>NUL
if not exist "%SystemDrive%\g2ldr" echo Not found '%SystemDrive%\g2ldr' . && exit 1
if not exist "%SystemDrive%\g2ldr.mbr" echo Not found '%SystemDrive%\g2ldr.mbr' . && exit 1
if not exist "%SystemDrive%\win32-loader\grub.cfg" echo Not found '%SystemDrive%\win32-loader\grub.cfg' . && exit 1
if not exist "%SystemDrive%\win32-loader\initrd.img" echo Not found '%SystemDrive%\win32-loader\initrd.img' . && exit 1
if not exist "%SystemDrive%\win32-loader\vmlinuz" echo Not found '%SystemDrive%\win32-loader\vmlinuz' . && exit 1
set id={01234567-89ab-cdef-0123-456789abcdef}
bcdedit /create %id% /d "Debian GUN/Linux" /application bootsector >NUL 2>NUL
bcdedit /set %id% device partition=%SystemDrive% >NUL 2>NUL
bcdedit /set %id% path \g2ldr.mbr >NUL 2>NUL
bcdedit /displayorder %id% /addlast >NUL 2>NUL
bcdedit /bootsequence %id% /addfirst >NUL 2>NUL
shutdown -r -t 0
[/crypto-block]