China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-15 00:21
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Closed]How to use batch processing to modify the parameters of the boot item in Boot.ini View 7,462 Replies 31
Floor 16 Posted 2006-10-29 02:09 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
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 ]
Floor 17 Posted 2006-10-31 10:44 ·  中国 黑龙江 哈尔滨 中移铁通
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
Originally posted by maotao at 2006-6-10 21:15:

I also flipped through the help of Bootcfg, and indeed there is no option to add custom switches.




The simplest way under XP:
bootcfg /raw "/Kernel=Kernel.exe " /id 1



bootcfg /raw: Adds the specified operating system load item to the operating system item in the section of the Boot.ini file in the form of a string.

/id 1: Specifies the line number of the operating system item to be updated in the section of the Boot.ini file. The first line after the title area is 1.

"/Kernel=Kernel.exe ": ????

Hehe!

[ Last edited by 0451lym on 2006-10-31 at 10:56 AM ]
Floor 18 Posted 2006-10-31 21:25 ·  中国 福建 泉州 电信
新手上路
Credits 2
Posts 1
Joined 2006-02-09 22:29
20-year member
UID 50122
Gender Male
Status Offline
I can't understand it??????
Floor 19 Posted 2006-11-01 08:38 ·  中国 江苏 扬州 联通
初级用户
Credits 44
Posts 14
Joined 2006-06-07 21:18
20-year member
UID 56712
Status Offline
Originally posted by 0451lym at 2006-10-31 10:44:




The simplest way under XP:
bootcfg /raw "/Kernel=Kernel.exe " /id 1



bootcfg /raw: In the section of the Boot.ini file, add to the operating system as a string...

This doesn't seem to work. You go to Boot.ini and check if some original switch items of that system menu entry are missing?
Floor 20 Posted 2006-11-01 20:10 ·  中国 黑龙江 哈尔滨 中移铁通
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
Originally posted by maotao at 2006-11-1 08:38:

This doesn't seem to work. Please check again in Boot.ini to see if some original switch items of that system menu entry are missing?


Microsoft Windows XP
(C) Copyright 1985-2001 Microsoft Corp.

D:\Documents and Settings\Administrator>bootcfg /raw "/Kernel=Kernel.exe " /id1
Success: The switch was added to the operating system entry "1" in the Boot.ini file.

D:\Documents and Settings\Administrator>c







My BOOT.INI is changed to:


timeout=5
default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS

multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="☆My Office System☆" /kernel=kernel.exe
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="★My Backup System★" /noexecute=optin /fastdetect
C:\grldr="
Floor 21 Posted 2006-11-01 20:25 ·  中国 黑龙江 哈尔滨 中移铁通
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
Just now I understood what you meant. You do it like this:

bootcfg /raw "/noexecute=optin /fastdetect/Kernel=Kernel.exe " /id 1

You can have any number of switches in the ""; just add all the ones you want!

D:\Documents and Settings\Administrator>bootcfg /raw "/noexecute=optin /fastdetect/Kernel=Kernel.exe " /id 1
Success: The switch was added to the operating system entry "1" in the Boot.ini file.

D:\Documents and Settings\Administrator>

My BOOT.INI has been changed to:

[boot loader]
timeout=5
default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="☆My Office System☆" /noexecute=optin /fastdetect/kernel=kernel.exe
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="★My Backup System★" /noexecute=optin /fastdetect
C:\grldr="My Image Restore System → 06 Autumn Edition!"
Floor 22 Posted 2006-11-01 21:03 ·  中国 江苏 扬州 电信
初级用户
Credits 44
Posts 14
Joined 2006-06-07 21:18
20-year member
UID 56712
Status Offline
Originally posted by 0451lym at 2006-11-1 20:25:
Just understood what you mean. Do it like this:
bootcfg /raw "/noexecute=optin /fastdetect/Kernel=Kernel.exe " /id 1

You can have any number of switches in the quotes. Just add all the ones you want...

It's okay like this, but you still need to understand some of the original switches first. If the original parameters were not like this,...
Floor 23 Posted 2006-11-01 23:12 ·  中国 黑龙江 哈尔滨 联通
高级用户
★★★
Credits 760
Posts 357
Joined 2005-10-10 22:33
20-year member
UID 43332
Status Offline
Originally posted by maotao at 2006-11-1 21:03:

This is no problem, but you still need to understand some original switches first. If the original parameters were not like this,...



The default switches in XP are just a few. There's no need to add many useless switches, right?
The problem should be simple, not complicated!
Floor 24 Posted 2006-11-01 23:31 ·  中国 广东 佛山 广东睿江科技有限公司
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
maotao wants to transform the system disk into a personalized one. The default settings of XP cannot meet the personalized needs - experts generally like DIY, and there are not many experts using MS's original installation discs.
尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。
Floor 25 Posted 2006-11-02 01:54 ·  中国 浙江 温州 电信
初级用户
★★
Credits 154
Posts 67
Joined 2006-10-31 00:50
19-year member
UID 68933
Gender Male
Status Offline
Got a lot out of it.. I won't go into details here anymore..
Floor 26 Posted 2006-11-05 02:32 ·  中国 广东 深圳 深圳坂田数据中心BGP多线
中级用户
★★
Credits 384
Posts 189
Joined 2005-10-19 13:12
20-year member
UID 43709
Gender Male
Status Offline
This pair is also useful, first save it, then gently give it a top.
Floor 27 Posted 2006-11-09 02:52 ·  中国 北京 海淀区 联通
初级用户
★★
Credits 122
Posts 54
Joined 2006-11-03 04:24
19-year member
UID 69380
Gender Male
Status Offline
What the person on floor 17 said is correct, but how to judge it's ID1? It seems that adding some batch processing is better.
Floor 28 Posted 2007-01-15 16:43 ·  中国 广东 深圳 福田区 电信
初级用户
Credits 48
Posts 20
Joined 2005-10-14 15:16
20-year member
UID 43494
Gender Male
Status Offline
I'm now going to use batch processing to find the line:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /execute /fastdetect /Kernel=Kernel.exe

And be able to reduce the string at the end of this line, for example, modify it to:

multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /execute /fastdetect

Also, I want to use only the functions built into XP system, without using external tools.
Floor 29 Posted 2007-01-17 12:47 ·  中国 广东 深圳 福田区 电信
初级用户
Credits 22
Posts 9
Joined 2007-01-16 16:01
19-year member
UID 76706
Gender Male
Status Offline
Great lords are really too handsome
Floor 30 Posted 2007-01-21 01:23 ·  中国 广东 阳江 电信
新手上路
Credits 8
Posts 4
Joined 2007-01-15 12:34
19-year member
UID 76585
Gender Male
Status Offline
Learning
Forum Jump: