![]() |
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-10 16:50 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Please enter the batch code to determine which partition the system is installed on. Wait, no, the correct translation should be: How to use batch processing to determine which partition the system is installed on? |
| Printable Version 2,503 / 11 |
| Floor1 afeichai | Posted 2006-11-23 02:26 |
| 初级用户 Posts 78 Credits 171 | |
|
For batch processing, I'm a layman. I saw the following code on Wuyou, which was originally given by a expert here.
The use of this code is to modify BOOT.INI when changing the XP boot screen. I tested it and it's very good. @echo off if exist boot.new del boot.new if not exist boot.ini goto :eof for /f "delims=" %%l in (boot.ini) do ( echo.%%l | find /i "/fastdetect" | find /v /i "/kernel">nul && echo %%l /kernel=kernel.exe||echo %%l )>>boot.new attrib -s -h -r boot.ini copy boot.new boot.ini>nul attrib +s +h +r boot.ini But there are also deficiencies. For multi - system, it will add /kernel=kernel.exe after /fastdetect. If you start to another system next time, it can't start. Also, the boot screens of 2000, XP, 2003 are different, and it can't judge the system. I wonder if batch processing can be used to do the following points? 1. Judge whether it is the XP system. If yes, carry out the following operations. If not, give a warning and then exit. 2. If it is the XP system, judge which partition the system is installed in, and then modify the corresponding system in BOOT.INI. 3. When modifying, automatically add a startup item of the current system at the end. I'm too bad to explain clearly. Give an example. For example, under BOOT.INI is like this [boot loader] timeout=5 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard Lite" /fastdetect multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Windows XP" /fastdetect I just want to add something after multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Windows XP" /fastdetect. Can it be done? Thank you for the answer. |
|
| Floor2 不得不爱 | Posted 2006-11-23 02:46 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
@echo off
if exist boot.new del boot.new if not exist boot.ini goto :eof for /f "delims=" %%l in (boot.ini) do ( echo.%%l | find /i "Windows XP" | find /v /i "/kernel">nul && echo %%l /kernel=kernel.exe||echo %%l )>>boot.new attrib -s -h -r boot.ini copy boot.new boot.ini>nul attrib +s +h +r boot.ini |
|
| Floor3 afeichai | Posted 2006-11-23 02:56 |
| 初级用户 Posts 78 Credits 171 | |
|
Thanks to the moderator. But yours still can't solve this problem. If all the multi-systems are XP, then it will still add to each one. I am using the following to solve the partition problem. How to judge that the system is installed in partition(2), this is what I care about, that is, there are systems in several partitions. When modifying, I only want to modify the current (actually running) system's, and leave the others unchanged.
@echo off if exist boot.new del boot.new if not exist boot.ini goto :eof for /f "delims=" %%l in (boot.ini) do ( echo.%%l | find /i "partition(2)\WINDOWS=" | find /v /i "/kernel">nul && echo %%l /kernel=kernel.exe||echo %%l )>>boot.new attrib -s -h -r boot.ini copy boot.new boot.ini>nul attrib +s +h +r boot.ini |
|
| Floor4 afeichai | Posted 2006-11-23 08:04 |
| 初级用户 Posts 78 Credits 171 | |
|
Maybe my expression is not clear enough
Please help, everyone, can batch processing be used to complete this task |
|
| Floor5 不得不爱 | Posted 2006-11-23 08:29 |
| 超级版主 Posts 2,044 Credits 5,310 From 四川南充 | |
|
This is related to the number of your hard drives
|
|
| Floor6 afeichai | Posted 2006-11-23 08:42 |
| 初级用户 Posts 78 Credits 171 | |
|
Suppose it is a hard disk, then how to judge the current system type and the partition where the system is located? Thanks.
|
|
| Floor7 namejm | Posted 2006-11-23 08:48 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
To determine the current system version, using the `ver` command is more accurate than looking for `boot.ini`. As for which partition the current system is installed on, using `%systemdrive%` or `%systemroot%` can accurately locate it. As for which record in `boot.ini` the current system corresponds to, it should not be difficult to get it using the `findstr` regular expression. Since I don't understand the meaning in `boot.ini`, I can only provide an idea for you.
|
|
| Floor8 afeichai | Posted 2006-11-23 09:02 |
| 初级用户 Posts 78 Credits 171 | |
Originally posted by namejm at 2006-11-22 07:48 PM: Thanks namejm, I often see your wonderful answers on Wuyou. Unfortunately, I know nothing about batch processing. The code I provided was also seen in the forum. Just love to tinker with XP systems. After testing this code, I found that it can replace manual work. But I think it's not perfect, so I raised the question The /kernel in BOOT.INI means that when booting, the file specified after it is used to replace ntoskrnl.exe to initialize the system, and the file after = can be saved in system32. In this way, the personalized boot screen can be realized. The ntoskrnl.exe of different systems is different and cannot be general, so the above question is raised. In addition, after modification, such as multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard Lite Edition" /fastdetect /kernel=kernel.exe It is better to change multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard Lite Edition" /fastdetect to multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard Lite Edition BAK" /fastdetect. In this way, in case of a bad modification, you can use this option to enter the system |
|
| Floor9 namejm | Posted 2006-11-23 09:37 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
I searched online for introductions to boot.ini, and after slightly understanding the meanings of various entries inside, I found a shortcoming: it can only record the operating system version series such as 2K or XP, but does not record the language category of that version (that is, whether it is the Chinese version or the English version, etc.); in addition, the number in partition(1) indicates which partition it is, and it is also necessary to make a judgment corresponding to a certain partition with a certain serial number (it seems that the Nth partition is not necessarily the drive letter represented by the Nth letter, because I am not very familiar with the partition situation, I don't know if this statement is correct), it seems relatively difficult to achieve universality.
[ Last edited by namejm on 2006-11-22 at 08:38 PM ] |
|
| Floor10 afeichai | Posted 2006-11-23 10:00 |
| 初级用户 Posts 78 Credits 171 | |
|
Thanks namejm
In BOOT.INI, "partition" only represents a partition. "partition(1)" represents the first partition, and it has nothing to do with the letter (drive letter) because the drive letter can be re - designated in NT - based systems. |
|
| Floor11 namejm | Posted 2006-11-23 10:12 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
If the partition is irrelevant to the drive letter, it will be very troublesome because %systemdrive% only gets the drive letter, not the partition number.
|
|
| Floor12 afeichai | Posted 2006-11-23 10:15 |
| 初级用户 Posts 78 Credits 171 | |
Originally posted by namejm at 2006-11-22 09:12 PM: Thanks. It seems that it can't be solved universally. Thank you, all great experts. This post can be closed. |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |