前提:find.exe findstr.exe gdisk.exe ghost.exe abc.bat在同一目录下,以下为abc.bat内容
Gdisk 1 >c:\ggg.txt
if not exist c:\ggg.txt echo error1&goto end
findstr /i "FAT32 NTFS" c:\ggg.txt>nul&&set flag1=1||echo error2&goto end
findstr /i "DIAGNOSTIC UNKNOWN" c:\ggg.txt>nul&&set flag2=1||(
find /i "AAAA" c:\ggg.txt>nul&&(Ghost /a)||(
echo error3”&goto end
)
)
find /i "BBBB" c:\ggg.txt>nul&&set flag3=1
if defined flag1 if defined flag2 if defined flag3 Ghost /b
:end
pause
Gdisk的功能是生成一个分区表,这段批处理是从生成的ggg.txt里判断分区类型并执行不同的ghsot
问题1:纯dos下for没有开关,是否能用第三方软件如strings来解决生成ggg.txt的问题,也就是说将上面的批处理修改成不要在C盘生成ggg.txt就能达到与上面同样的效果(纯dos是否一定要生成临时文件?)
问题2:abc.bat批处理在纯dos下执行后出现很多错误(echo没有关)
F:\>abc.bat
F:\>gdisk.exe 1 >C:\ggg.txt
F:\>if not exist c:\ggg.txt echo error1&goto end
F:\>findstr /i "FAT32 NTFS" c:\ggg.txt>nul&&set flag1=1||echo error&goto end
Syntax error
F:\>findstr /i "DIAGNOSTIC UNKNOWN" c:\ggg.txt>nul&&set flag2=1||(
Syntax error
F:\> find /i "AAAA" c:\ggg.txt>nul&&(Ghost /a)||(
Syntax error
F:\> echo error3”&goto end
error3”&goto end
F:\> )
Bad command or file name
F:\>)
Bad command or file name
F:\>find /i "BBBB" c:\ggg.txt>nul&&set flag3=1
File creation error
F:\>if defined flag1 if defined flag2 if defined flag3 Ghost /b
Syntax error
不知道我写得够不够清楚,有不清楚的麻烦大家跟贴,我是确实搞不懂为什么这段批处理会出现这么多错误了
Gdisk 1 >c:\ggg.txt
if not exist c:\ggg.txt echo error1&goto end
findstr /i "FAT32 NTFS" c:\ggg.txt>nul&&set flag1=1||echo error2&goto end
findstr /i "DIAGNOSTIC UNKNOWN" c:\ggg.txt>nul&&set flag2=1||(
find /i "AAAA" c:\ggg.txt>nul&&(Ghost /a)||(
echo error3”&goto end
)
)
find /i "BBBB" c:\ggg.txt>nul&&set flag3=1
if defined flag1 if defined flag2 if defined flag3 Ghost /b
:end
pause
Gdisk的功能是生成一个分区表,这段批处理是从生成的ggg.txt里判断分区类型并执行不同的ghsot
问题1:纯dos下for没有开关,是否能用第三方软件如strings来解决生成ggg.txt的问题,也就是说将上面的批处理修改成不要在C盘生成ggg.txt就能达到与上面同样的效果(纯dos是否一定要生成临时文件?)
问题2:abc.bat批处理在纯dos下执行后出现很多错误(echo没有关)
F:\>abc.bat
F:\>gdisk.exe 1 >C:\ggg.txt
F:\>if not exist c:\ggg.txt echo error1&goto end
F:\>findstr /i "FAT32 NTFS" c:\ggg.txt>nul&&set flag1=1||echo error&goto end
Syntax error
F:\>findstr /i "DIAGNOSTIC UNKNOWN" c:\ggg.txt>nul&&set flag2=1||(
Syntax error
F:\> find /i "AAAA" c:\ggg.txt>nul&&(Ghost /a)||(
Syntax error
F:\> echo error3”&goto end
error3”&goto end
F:\> )
Bad command or file name
F:\>)
Bad command or file name
F:\>find /i "BBBB" c:\ggg.txt>nul&&set flag3=1
File creation error
F:\>if defined flag1 if defined flag2 if defined flag3 Ghost /b
Syntax error
不知道我写得够不够清楚,有不清楚的麻烦大家跟贴,我是确实搞不懂为什么这段批处理会出现这么多错误了
