|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『楼 主』:
请问,如何用批处理来判断系统安装在哪个分区?
使用 LLM 解释/回答一下
对于批处理,我是门外汉。我在无忧看到了如下代码,原来也是这里的大侠给的
这段代码的用处是用来更换XP开机画面的时候来修改BOOT.INI的。我试验了,非常好。
@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
但也有不足,对于多系统来说,他会把/fastdetect后面都加上/kernel=kernel.exe,如果下次启动到另外系统就无法启动了。另外,开机画面2000,XP,2003都不同,不能判断系统
不知道是否能用批处理来做到下面的几点?
1.判断是否是XP系统,是,进行后面的操作,否,提出警告,然后退出
2.如果是XP系统,判断该系统安装的哪个分区,然后修改BOOT.INI里面相应的系统
3.在修改的时候,自动添加一项现在系统的启动项目在最后。
我太菜了,说不清楚,给个例子
如BOOT.INI下是这样的
[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 精简版" /fastdetect
multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Windows XP" /fastdetect
我只想在multi(0)disk(0)rdisk(0)partition(2)\WINDOWS="Windows XP" /fastdetect
后面加,请问可以做到吗?
多谢解答
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
timeout=5
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
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.
|
|
2006-11-23 02:26 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
@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
@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
|

我的网络U盘 我的网络第2个U盘
论坛软件下载链接
灵雨飘零论坛
论坛新手必读,所有人的基本行为准则
刷QQ空间人气、留言的小软件 |
|
2006-11-23 02:46 |
|
|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
多谢版主。但你的好像也不能解决这个问题。如果多系统都是XP,那他还是会给每个都加上的。我是用下面的解决分区问题,如何来判断系统安装在partition(2),这个是我关心的,也就是说,几个分区都有系统,修改的时候,我只想修改当前(真在运行的)系统的,其他的不动。
@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
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
|
|
2006-11-23 02:56 |
|
|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
也许是我的表达不够清晰吧
还请各位大侠帮忙看看,能否用批处理完成这个任务
Maybe my expression is not clear enough
Please help, everyone, can batch processing be used to complete this task
|
|
2006-11-23 08:04 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2006-11-23 08:29 |
|
|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
假设是一块硬盘,那么如何来判断当前系统类型和系统所在分区呢?
谢谢了
Suppose it is a hard disk, then how to judge the current system type and the partition where the system is located? Thanks.
|
|
2006-11-23 08:42 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
判断当前系统版本,使用 ver 命令比查找 boot.ini 更准确。至于当前系统安装在哪个分区上,则使用 %systemdive% 或者 %systemroot% 可以准确定位。至于当前系统对应 boot.ini 中的哪条记录,用 findstr 正则表达式应不难得到。因我对 boot.ini 中的含义不甚了解,只能提供个思路给你。
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.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-11-23 08:48 |
|
|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Originally posted by namejm at 2006-11-22 07:48 PM:
判断当前系统版本,使用 ver 命令比查找 boot.ini 更准确。至于当前系统安装在哪个分区上,则使用 %systemdive% 或者 %systemroot% 可以准确定位。至于堮..
多谢namejm,经常在无忧看到你精彩的回答。可惜我对批处理一无所知。我提供的代码也是在论坛里面看到的。只是爱捣鼓XP系统。看到了这个代码后试验了下,发现可以代替手工劳动了。但觉得不够完美,提出问题
/kernel在BOOT.INI的含义是开机的时候,用他后面指定的文件来代替ntoskrnl.exe初始化系统,=后面的文件保存在system32中即可。这样就可以个性化开机画面了。不同系统ntoskrnl.exe不同,不能通用,所以提出上面的问题。
另外,在修改后,如
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard 精简版" /fastdetect /kernel=kernel.exe
最好能再把multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard 精简版" /fastdetect 改为
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Standard 精简版BAK" /fastdetect,这样,万一改坏了,可以用这个选项进入系统
Originally posted by namejm at 2006-11-22 07:48 PM:
Judging the current system version, using the ver command is more accurate than finding boot.ini. As for which partition the current system is installed on, using %systemdrive% or %systemroot% can accurately locate it. As for 堮..
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
|
|
2006-11-23 09:02 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
网上搜索了一下boot.ini的介绍,稍微了解了一下里面各个记录的含义,发现它有个缺憾:只能记录操作系统是2K还是XP等版本系列,但是并没有记录该版本的语言类别(即究竟是中文版还是英文版等等);另外,partition(1)里面的数字表示的是第几个分区,还得对某个分区对应着某个序号做个判断(似乎第N个分区不一定是第N个字母所表示的盘符,因为我对分区情况不是很了解,不知道这个说法是否正确),要做到通用性似乎比较困难。
Last edited by namejm on 2006-11-22 at 08:38 PM ]
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 ]
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-11-23 09:37 |
|
|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
谢谢namejm
BOOT.INI里面,partition只代表分区partition(1)代表第一分区,和字母(盘符)无关,因为盘符在NT系统中可以重新指定。
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.
|
|
2006-11-23 10:00 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
如果分区和盘符无关的话,那就很麻烦了,因为 %systemdrive% 取到的只是盘符,而不能获取分区的序号。
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.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-11-23 10:12 |
|
|
afeichai
初级用户
 
积分 171
发帖 78
注册 2006-11-22
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by namejm at 2006-11-22 09:12 PM:
如果分区和盘符无关的话,那就很麻烦了,因为 %systemdrive% 取到的只是盘符,而不能获取分区的序号。
多谢了。看样子是不能通用解决了。谢谢各位大侠。此贴可结了
Originally posted by namejm at 2006-11-22 09:12 PM:
If the partition is irrelevant to the drive letter, then it's very troublesome, because %systemdrive% only gets the drive letter, not the partition number.
Thanks. It seems that it can't be solved universally. Thank you, all great experts. This post can be closed.
|
|
2006-11-23 10:15 |
|