![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-29 08:05 |
47,816 topics / 349,916 posts / today 0 new / 48,265 members |
| DOS批处理 & 脚本技术(批处理室) » [Closed]How to use batch processing to modify the parameters of the boot item in Boot.ini |
| Printable Version 7,764 / 31 |
| Floor1 maotao | Posted 2006-06-07 23:38 |
| 初级用户 Posts 14 Credits 44 | |
|
For example, my BOOT.INI is like this
Now I want to use a batch script to find the line multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /execute /fastdetect And be able to add a 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 /Kernel=Kernel.exe I'm a newbie, I sincerely ask all experts for your advice, and I hope you don't laugh at me. [ Last edited by willsort on 2006-6-10 at 22:48 ] |
|
| Floor2 Climbing | Posted 2006-06-08 01:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Worry-free Lao Maotao? Hehe, the world is too small.
But before posting for help, it's still recommended that you first read the forum rules. At least make it clear about the running environment of your batch script. The simple method (I usually only use simple methods, my brain can't handle complicated ones) is that you can download a third-party DOS software called change.exe, and then study its usage (just type change /?). The complicated one恐怕就要 use things like find, findstr, and also go through complicated other processing to complete the task. NND, if Microsoft provided a built-in sed, this thing would be too simple. |
|
| Floor3 Climbing | Posted 2006-06-08 01:07 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Well, I suddenly thought that if the bootcfg command is flexibly run, it might make this operation simpler.
|
|
| Floor4 willsort | Posted 2006-06-08 10:53 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re maotao:
The following code can be run in CMD to make corresponding modifications to boot.ini in the current path. In addition, by roughly flipping through the help documentation of bootcfg, the useful switch /Addsw may only add a few limited fixed switches to boot.ini, and /kernel is not included in it. [ Last edited by willsort on 2006-6-8 at 10:57 ] |
|
| Floor5 Climbing | Posted 2006-06-08 11:17 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
Brilliant, really brilliant! Brother wil, I'm extremely佩服!
|
|
| Floor6 piziliu2004 | Posted 2006-06-08 14:03 |
| 中级用户 Posts 139 Credits 321 | |
|
"!!" example for /f %%i in (3.txt) do set str=!str!%%i As the question says!str! means the str variable, so why can't %str% be used.
"|", "||", "&", "&&" are often seen in batch processing. What are the specific functions? I'm a bit confused here. Muddled.! Take the batch processing written by moderator willsort as an example: Please explain the mystery. The following batch processing is really classic喔.! for /f "delims=" %%l in (boot.ini) do ( echo.%%l | find/i "/fastdetect">nul && echo %%l /kernel=kernel.exe||echo %%l )>>boot.new |
|
| Floor7 piziliu2004 | Posted 2006-06-08 15:23 |
| 中级用户 Posts 139 Credits 321 | |
|
Detailed Explanation of Batch Command Connectors and Pipes and Their Differences
up |
|
| Floor8 bagpipe | Posted 2006-06-08 17:36 |
| 银牌会员 Posts 425 Credits 1,144 From 北京 | |
|
The main function of this code is to retrieve each line of the BOOT.INI file. If a line with "/fastdetect" is found, the parameter "/kernel=kernel.exe" is added after this line. Then, the file is saved as boot.new. If no line with "/fastdetect" is found, the entire content of the BOOT.INI file is saved as the boot.new file. As follows:
If the original BOOT.INI file is [boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /kernel=kernel.exe multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Professional" /fastdetect /kernel=kernel.exe I think the building block should be able to see the differences. If there is no "/fastdetect", then the content of the boot.new file should be the same as the original BOOT.INI content. Explanation: The sentence echo.%%l | find/i "/fastdetect">nul && echo %%l /kernel=kernel.exe||echo %%l The | pipe character means that the output of the first command is used as the input of the second command, that is, the content of echo %%i is displayed as the content for find /i to search. >nul means that the normal output of executing this command is not displayed && means that if the previous command is executed successfully, the subsequent statement is executed; if it is not executed successfully, the subsequent statement is not executed || means that if the executed statement fails, this sentence is executed. For example, if there is no line with the "/fastdetect" character in the file, then execute echo %%i. If the previous command is executed successfully, this sentence is not executed. Oh, typing is really tiring, that's probably all... Go away in tears............. Then after execution, it should be: [boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect multi(0)disk(0)rdisk(0)partition(1)\WINNT="Microsoft Windows 2000 Professional" /fastdetect |
|
| Floor9 willsort | Posted 2006-06-08 20:50 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
───────────────── Moderation Record ───────────────── Performed by: Will Sort Operation: Merge topic {21100} Batch Command Hunting Construction and Detailed Explanation of Their Differences -> Posts 6, 7, 8 Explanation: The operated topic has a direct contextual connection with this topic Punishment: Deduct 8 points, including 6 points awarded for posting this topic and 2 points deducted for duplicate topic penalty ───────────────── Moderation Record ───────────────── |
|
| Floor10 maotao | Posted 2006-06-10 21:15 |
| 初级用户 Posts 14 Credits 44 | |
Originally posted by Climbing at 2006-6-8 01:00: Hehe, it's exactly me. Regarding the forum rules, I'm sorry, I'm a first-time visitor to the DOS Union and didn't read it clearly. There were people posting on the Worry-free forum asking for help regarding Boot.INI modification, so I rushed to post here for help. If there is any violation of the forum rules, please forgive me, moderator. Originally posted by willsort at 2006-6-8 10:53: Thanks for the reply from Brother WillSort. I also flipped through the Bootcfg help, and indeed there is no option to add a custom switch. Regarding the third-party software change.exe recommended by Moderator Climbing. Laomaotao has used it, and it's really easy to use. But I just want to try, can batch processing achieve it without using third-party software. Brother Will's code is concise and efficient, Laomaotao is deeply admired, and really needs to study hard. But can you be a good person to the end and help one more time, that is, if there is already /kernel=kernel.exe in the current system switch, how to handle it? I hope Brother Will will reply. In this regard, Laomaotao is not proficient at all, thank you first! |
|
| Floor11 willsort | Posted 2006-06-10 22:03 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re maotao:
Regarding the issue of avoiding repeated modifications, adding a reverse find should work. The code is as follows. If there are any other corrections or requirements, feel free to continue pointing them out. Also, welcome brother to come here to exchange experiences with everyone. The version management operation on floor 9 is for piziliu2004 on floor 6, which made you frightened :) |
|
| Floor12 namejm | Posted 2006-06-10 22:08 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Adding a judgment statement based on the willsort code can meet the needs:
When replying, I found that willsort has already given a solution. Hehe, then I'll add some casual remarks and post it again. [ Last edited by namejm on 2006-6-10 at 22:12 ] |
|
| Floor13 maotao | Posted 2006-06-10 22:36 |
| 初级用户 Posts 14 Credits 44 | |
Originally posted by willsort at 2006-6-10 22:03: Thanks to Brother Willsort for helping again. I think this time it can solve the problem for the friend who asked for help on Wuyou. Hehe, just came to the DOS Union for the first time and got help from Brother Willsort. I'm very grateful! In the future, if there is any need for help with Lao Maotao, I won't be polite! |
|
| Floor14 willsort | Posted 2006-06-11 16:54 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re maotao:
Because considering that the script needs to be applied to actual projects, and also the importance of boot.ini, so various operation links are considered as much as possible, and operation status judgment and prompts are added. Everyone can also check again whether the script has omitted some links that have not been processed. It can be seen that this version of the script is much more complicated compared with the previous two versions, but the basic algorithm remains unchanged, which is the inevitable impact brought by code engineering. |
|
| Floor15 maotao | Posted 2006-06-13 00:35 |
| 初级用户 Posts 14 Credits 44 | |
|
Hehe, this is really an eye - opener, it's really good!
|
|
| 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |