中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-09 09:31
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 怎么生成一个BOOT.INI 查看 1,938 回复 19
16 发表于 2008-08-08 02:11 ·  中国 广东 广州 海珠区 电信
银牌会员
★★★
积分 1,206
发帖 517
注册 2007-03-25 01:18
19年会员
UID 82819
性别 男
状态 离线
Originally posted by shayulei at 2008-8-7 09:11 AM:
谢谢,不过C盘不一定在第一个分区上,有可能在第二个分区上,所以你设变量的方法,我认为行不通



呵呵,麻烦你把boot.ini文件理解一下了才来发言..

最少你要明白那几个参数是什么意思。

还有什么是分区.麻烦你也多研究一下。
知,不觉多。不知,乃求知
17 发表于 2008-08-08 02:22 ·  中国 广东 广州 海珠区 电信
银牌会员
★★★
积分 1,206
发帖 517
注册 2007-03-25 01:18
19年会员
UID 82819
性别 男
状态 离线

@Echo off & setlocal EnableDelayedExpansion
set "num=0"
for %%i in (c: d: e: f: g:) do (
set /a num+=1
if /i "%%i"=="%SystemDrive%" call :Boot_Output
)
goto :end
:Boot_Output

echo default=multi(0)disk(0)rdisk(0)partition(%num%)\WINNT>>boot.ini

goto :EOF

:end


测试了一下代码,发现是少了一个不区分大小写的参数/i..

代码页中已经修正..
知,不觉多。不知,乃求知
18 发表于 2008-08-08 11:12 ·  中国 浙江 湖州 联通
中级用户
★★
积分 301
发帖 74
注册 2005-02-25 00:00
21年会员
UID 36491
性别 男
状态 离线
我已经写好了,谢谢大家
for /f "Tokens=1-3" %%i in ('diskpart /s z:\diskpart\Testc.txt ^| find "*" ') do set /a SystemPart=%%k
if %SystemPart% LSS 1 GOTO error
if %systemPart% GTR 10 goto error
19 发表于 2008-08-08 11:13 ·  中国 浙江 湖州 联通
中级用户
★★
积分 301
发帖 74
注册 2005-02-25 00:00
21年会员
UID 36491
性别 男
状态 离线
@echo off
attrib -s -h -r c:\boot.ini
attrib -s -h -r c:\bootxp.ini
for /f "Tokens=1-3" %%i in ('diskpart /s z:\diskpart\Testc.txt ^| find "*" ') do set /a SystemPart=%%k
if %SystemPart% LSS 1 GOTO error
if %systemPart% GTR 10 goto error

::生成boot.ini
echo [boot loader] > c:\boot.ini
echo timeout=30 >> c:\boot.ini
echo default=multi(0)disk(0)rdisk(0)partition(%SystemPart%)\WINDOWS >> c:\boot.ini
echo [operating systems] >> c:\boot.ini
echo multi(0)disk(0)rdisk(0)partition(%systemPart%)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect /detecthal >> c:\boot.ini

::生成bootxp.ini
echo [boot loader] > c:\bootxp.ini
echo timeout=30 >> c:\bootxp.ini
echo default=multi(0)disk(0)rdisk(0)partition(%SystemPart%)\WINDOWS >> c:\bootxp.ini
echo [operating systems] >> c:\bootxp.ini
echo multi(0)disk(0)rdisk(0)partition(%systemPart%)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetect >> c:\bootxp.ini

goto :EOF
:error
echo 测试系统盘出错,请手处理boot.ini & goto :EOF

:end
20 发表于 2008-08-08 13:40 ·  中国 广东 广州 番禺区 电信
银牌会员
★★★
积分 1,206
发帖 517
注册 2007-03-25 01:18
19年会员
UID 82819
性别 男
状态 离线
boot.ini文件处理完后需要加多

attrib +s +h +r +a boot.ini

另外,你的脚本是怎么判断的?

把你的 diskpart /s 的脚本拿出来看看?

是不是你用的双硬盘呢?


感觉你的脚本有点多此一举。
知,不觉多。不知,乃求知
论坛跳转: