Originally posted by willsort at 2006-6-11 16:54:
:: ModBoot.cmd - V3 - Modify of boot.ini
:: Will Sort - 2006-6-11 - CMD@WinXP
@echo off
if not exist boot.ini echo Not found boot.ini!&goto :eof
if exist %temp%\boot.new del /f /a %temp%\boot.new
find/i "/kernel=" boot.ini>nul && echo Modified boot.ini! && goto :eof
for /f "delims=" %%l in (boot.ini) do (
echo.%%l | find/i "/fastdetect" >nul && echo %%l /kernel=kernel.exe || echo %%l
)>>%temp%\boot.new
find/i "/kernel" %temp%\boot.new>nul 2>nul
if errorlevel 1 echo Fail to parse boot.ini!&goto :eof
attrib -s -h -r boot.ini
copy boot.ini %temp%\boot.bak>nul&&echo Pass to backup boot.ini.
copy %temp%\boot.new boot.ini>nul 2>nul
find/i "/kernel" boot.ini>nul 2>nul
if not errorlevel 1 echo Pass to wrtie boot.ini.
if errorlevel 1 copy %temp%\boot.bak boot.ini>nul & echo Fail to wrtie boot.ini!
attrib +s +h +r boot.ini
del %temp%\boot.new & del %temp%\boot.bak
I took a look at the code written by Brother willsort, and it's really good, but I can't help but have some doubts about a certain statement in it, especially the sentence "copy %temp%\boot.new boot.ini>nul 2>nul".
It's not hard to see that the above batch processing written by Brother willsort should be run in the root directory of the system drive, and there is no statement to delete the "boot.ini" file in this code, but this sentence later makes me doubtful: "copy %temp%\boot.new boot.ini>nul 2>nul", here it will copy "%temp%\boot.new" to the current working directory, that is, copy to the root directory of the system drive, and change the file name to "boot.ini", and at this time there is already a "boot.ini" file in the root directory of the system drive, then the copy command will ask you whether to rewrite the original "boot.ini" file, and Brother willsort just simply adds the " >nul 2>nul" shielding statement at the back, in this way, the system seems to be deadlocked in a state of asking, of course, the CMD window has no prompts at all. This obviously doesn't achieve our purpose, and the result is obviously a copy failure.
The above is just a small doubt I have about a statement in the batch processing written by Brother willsort. If I made any mistakes, please forgive me from everyone and Brother willsort.
[ Last edited by lxmxn on 2006-10-29 at 02:13 AM ]
