|
下面的批处理能在NT下运行,高手看看能不能改造使得它能在MSDOS下运行
主要是FOR /F
可以使用DOS下能用的第三方程序。
@ECHO OFF
CLS
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
:: Give NT5.X Source Directory with Location of DOSNET.INF
SET ntsource=
SET bttarget=
SET btdir=$WIN_NT$.~BT
::SET btdir=XPBT
IF "%btdir%" == "" (
echo.
echo Bootfolder Name NOT Valid
echo.
goto _end_quit
)
:_main
ECHO.
ECHO MAKEBT.cmd Batch Program for Windows NT5.X
echo.
echo Parse DOSNET.INF for making Windows NT5.X Setup Bootfolder $WIN_NT$.~BT
echo.
echo 1) Change Windows NT5.X Source Path , currently [%ntsource%]
echo.
echo 2) Change Destination Directory , currently [%bttarget%]
echo.
echo 3) Make Target Windows NT5.X Setup Bootfolder %btdir%
echo.
echo Q) Quit
echo.
set _ok=
set /p _ok= Enter your choice:
if "%_ok%" == "1" goto _getsrc
if "%_ok%" == "2" goto _gettmp
if "%_ok%" == "3" goto _mktemp
if /I "%_ok%" == "q" goto _end_quit
ECHO.
ECHO ***** NOT in Menu - Wrong Selection - Try Again *****
ECHO.
pause
goto :_main
:_getsrc
set src_ok=
echo.
echo Please give the location to your Windows NT5.X Source Files
ECHO e.g if you have C:\ntsource\I386 type C:\ntsource
ECHO.
set /p src_ok= Enter Source path:
ECHO %src_ok%|FIND " "
IF "%ERRORLEVEL%"=="0" (
echo.
echo ***** Error: Selected Path does Contain Spaces and is Invalid *****
echo.
echo Solution: Rename Folder or Change to Path without Spaces
echo.
pause
goto _main
)
if exist %src_ok%\i386\nul (
SET ntsource=%src_ok%
) else (
echo.
echo Error: The path %src_ok% does not contain Windows NT5.X Source Files
echo.
pause
)
goto _main
:_gettmp
set _ok=
echo.
echo Give Target Directory Path for making Windows NT5.X Setup Bootfolder %btdir%
ECHO.
set /p _ok= Enter Target Directory Path:
if exist !_ok!\nul (
SET bttarget=!_ok!
if EXIST !bttarget!\%btdir%\nul (
echo.
echo ***** WARNING Existing NT5.X Bootfolder %btdir% Detected *****
echo ***** Files will be Replaced when Making %btdir% Folder *****
echo.
pause
)
) ELSE (
echo Directory Path !_ok! Does NOT Exists, Make Selection Again
echo.
pause
)
goto _main
:_mktemp
IF "%ntsource%" == "" (
echo Please give first valid NT5.X Source Path
echo.
pause
goto _main
)
IF "%bttarget%" == "" (
echo Please give first valid Destination Directory
echo.
pause
goto _main
)
:: Make Destination directories for NT5.X Setup Bootfolder
IF NOT EXIST %bttarget%\%btdir%\nul MD %bttarget%\%btdir%
IF NOT EXIST %bttarget%\%btdir%\system32\nul MD %bttarget%\%btdir%\system32
SET cpyflag=0
FOR /F "tokens=1,2,3* delims=, " %%G IN (%ntsource%\I386\DOSNET.INF) DO (
SET FTAG=%%G
SET FTAG=!FTAG:~0,13!
IF "!FTAG!"=="[FloppyFiles." (
SET cpyflag=1
IF "%%G"=="[FloppyFiles.x]" SET cpyflag=0
) ELSE (
SET FTAG=!FTAG:~0,1!
IF "!FTAG!"=="[" SET cpyflag=0
IF "!cpyflag!"=="1" (
SET btfile=%%H
IF "%%I"=="" (
SET btfile=!btfile:~0,-1!*
xcopy %ntsource%\I386\!btfile! %bttarget%\%btdir% /i /k /y /h
) ELSE (
copy /y %ntsource%\I386\%%H %bttarget%\%btdir%\%%I
)
)
)
)
ECHO.
ECHO Making Windows NT5.X Setup Bootfolder %bttarget%\%btdir% - READY
GOTO :_end_quit
:Syntax
ECHO.
ECHO BT_folder.cmd, Version 1.0 for Windows NT5.X
ECHO.
ECHO Parse DOSNET.INF for making Windows NT5.X Setup Bootfolder $WIN_NT$.~BT
ECHO.
:_end_quit
ECHO.
ECHO End BT_folder.cmd Batch Program
ECHO.
pause
EXIT
[ 本帖最后由 zhaohj 于 2010-4-3 17:30 编辑 ] |
|