home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2004 July & August
/
PCWorld_2004-07-08_cd.bin
/
Software
/
vyzkuste
/
xp
/
pebuilder3032.exe
/
plugin
/
pehdinst
/
pehdinst.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
2004-02-17
|
7KB
|
219 lines
@echo off
title BartPE Harddisk Installer v1.0.3
echo BartPE Harddisk Installer v1.0.3
echo Copyright (c) 2003 Bart Lagerweij. All rights reserved.
echo This program is free software. Use and/or distribute it under
echo the terms of the Nu2 License (see nu2lic.txt file).
setlocal
%~d0
cd "%~dp0"
for %%i in (_source _target) do set %%i=
:_arg
for %%i in (-h -H) do if "%%i" == "%1" goto _usage
if "%1" == "-b" goto _b
if "%1" == "-f" goto _f
if "%_source%" == "" if not "%1" == "" goto _1
if "%_target%" == "" if not "%1" == "" goto _2
goto _start
:_b
set _go=_bootini
goto _next
:_f
set _go=_fresh
goto _next
:_1
set _source=%1
goto _next
:_2
set _target=%1
goto _next
:_next
shift
if "%1" == "" goto _start
goto _arg
:_usage
echo.
echo Usage: %~n0 [Options] [SourcePath] [TargetPath]
echo.
echo SourcePath: the path where bartPE can be found. By default the drive where
echo %~n0 is located is used.
echo TargetPath: is the path to where bartPE will be installed.By default drive
echo C: is used.
echo Options:
echo -b Install BartPE into boot.ini (choice 1)
echo -f Install BartPE as primary OS (choice 2)
echo -h Help
goto _end
:_start
echo PEHDINST: Checking for required file(s)...
for %%i in (mkbt.exe) do if not exist %%i (
echo PEHDINST: Required file %%i not found!
goto _abort)
if "%_source%" == "" set _source=%~d0
if "%_target%" == "" set _target=c:
echo PEHDINST: Source="%_source%" Target="%_target%"
if not exist "%_source%\i386\setupldr.bin" (
echo PEHDINST: Invalid BartPE source, file "%_source%\i386\setupldr.bin" not found.
goto _usage)
:_main
if not "%_go%" == "" goto %_go%
echo.
echo 1) Install BartPE to %_target%, next to your existing Windows (boot.ini).
echo This will:
echo - Install %_target%\peboot.bin and %_target%\peldr.
echo - Add peboot.bin to your boot.ini file.
echo - Remove %_target%\minint and %_target%\programs and copy it from
echo %_source%.
echo 2) Install BartPE to %_target%, as the primairy OS.
echo This will:
echo - Delete all partitions on disk 0 and create a new partition and a NTFS
echo volume for BartPE (only the first time).
echo - Remove %_target%\minint and %_target%\programs and copy it from
echo %_source%.
echo Q) Quit.
echo.
:_mainch
set _ok=
set /p _ok=Enter your choice [1/2/Q] :
if "%_ok%" == "1" goto _bootini
if "%_ok%" == "2" goto _fresh
if "%_ok%" == "q" goto _end
goto :_mainch
:_bootini
echo PEHDINST: Checking if NT Loader is installed on drive %_target%
if not exist %_target%\ntldr (
echo PEHDINST: Oops, file "%_target%\ntldr" not found.
goto _abort)
echo PEHDINST: Checking if boot.ini is on drive %_target%
if not exist %_target%\boot.ini (
echo PEHDINST: Oops, file "%_target%\ntldr" not found.
goto _abort)
if exist %_target%\peboot.bin goto _instldr
echo PEHDINST: Installing PE Bootsector (peboot.bin)
mkbt.exe -x -c %_target% %_target%\peboot.bin
if errorlevel 1 goto _abort
echo PEHDINST: Updating peboot.bin
nt2peldr.exe %_target%\peboot.bin
if errorlevel 1 goto _abort
echo PEHDINST: Updating boot.ini
findstr /I /B /L /V "%_target%\peboot.bin" %_target%\boot.ini > %_target%\boot$.ini
echo %_target%\peboot.bin="Boot BartPE (by PE Builder)" >> %_target%\boot$.ini
attrib -r -h -s %_target%\boot.ini
if errorlevel 1 goto _abort
del /q /f %_target%\boot.ini
if errorlevel 1 goto _abort
ren %_target%\boot$.ini boot.ini
if errorlevel 1 goto _abort
attrib +r +h +s %_target%\boot.ini
:_instldr
echo PEHDINST: Installing PE Loader (peldr)
rem copy %~d0\i386\setupldr.bin %_target%\ntldr
copy %_source%\i386\setupldr.bin %_target%\peldr
if errorlevel 1 goto _abort
goto _inst
:_fresh
echo Check if running bartPE...
reg.exe query HKLM\system\currentcontrolset\control\minint >nul 2>&1
if errorlevel 1 goto _nowinpe
:_fresh1
echo Listing disk(s) and disk 0 details...
diskpart.exe /s "pelist.txt"
if errorlevel 1 goto _abort
echo.
echo Do you want to install BartPE from drive %_source% to disk 0?
echo -- THIS WILL TOTALLY ERASE ALL DATA ON YOUR DISK! --
echo.
set _ok=
set /p _ok=To continue type "YES" (uppercase without quotes) :
if "%_ok%" == "YES" goto _insthd
echo PEHDINST: You typed "%_OK%", quitting...
goto _end
:_nowinpe
echo.
echo PEHDINST: Not booted from BartPE, quitting...
goto _end
:_exist
echo PEHDINST: bartPE is already installed on %_target%\
echo PEHDINST: When reinstalling again only the files will be recopied.
echo PEHDINST: The partition/volume will not be reformatted!
echo.
set _ok=
echo PEHDINST: Do you want to reinstall?
set /p _ok=Type "y" for Yes, "n" for No, "f" for Fresh install [Y/N/F] :
if "%_ok%" == "Y" goto _inst
if "%_ok%" == "y" goto _inst
if "%_ok%" == "N" goto _end
if "%_ok%" == "n" goto _end
if "%_ok%" == "F" goto _fresh
if "%_ok%" == "f" goto _fresh
:_insthd
echo.
echo PEHDINST: Creating new NTFS partition on disk 0
diskpart.exe /s "pepart.txt"
if errorlevel 1 goto _abort
echo Formating %_target%
format %_target% /fs:ntfs /v:bartPE /q /force
if errorlevel 1 goto _abort
echo PEHDINST: Installing ntdetect
copy %_source%\i386\ntdetect.com %_target%\
if errorlevel 1 goto _abort
echo PEHDINST: Installing ntldr
copy %_source%\i386\setupldr.bin %_target%\ntldr
if errorlevel 1 goto _abort
:_inst
echo PEHDINST: Installing bartPE files from drive %_source% to %_target%\
call :_copy i386 minint
if errorlevel 1 goto _abort
call :_copy programs programs
if errorlevel 1 goto _abort
copy %_source%\winbom.ini %_target%\winbom.ini
if errorlevel 1 goto _abort
echo.
echo PEHDINST: Installation completed...
goto _end
:_copy
if "%~1" == "" goto :eof
if "%~2" == "" goto :eof
if not exist "%_source%\%~1" goto :eof
if exist "%_target%\%~2" (
echo PEHDINST: Checking for BartPE tag file...
if not exist "%_target%\%~2\bartpe.tag" goto _tagerr
echo PEHDINST: Removing %_target%\%~2
rmdir /s /q "%_target%\%~2\")
if errorlevel 1 goto :eof
mkdir "%_target%\%~2\"
if errorlevel 1 goto :eof
echo Tag file for BartPE do not remove! > "%_target%\%~2\bartpe.tag"
if errorlevel 1 goto :eof
echo PEHDINST: Copying files from "%_source%\%~1" to "%_target%\%~2"
xcopy /e /s "%_source%\%~1\*.*" "%_target%\%~2\"
goto :eof
:_tagerr
echo PEHDINST: Tag file "%_target%\%~2\bartpe.tag" not found!
echo PEHDINST: Not safe to remove directory!
echo.
echo Workaround:
echo You could delete the folder "%_target%\%~2" manually and restart the installation...
rem set errorlevel to 1 by (mis)using color
color 00
goto :eof
:_abort
echo.
echo PEHDINST: Aborted...
endlocal
pause
goto :eof
:_end
endlocal
echo.
echo PEHDINST: Done
pause