中国DOS联盟

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

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

中国DOS联盟论坛
现在时间是 2026-08-03 13:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 用P处理命令在任意分区中查找并运行一个命令 查看 753 回复 5
楼 主 用P处理命令在任意分区中查找并运行一个命令 发表于 2007-03-05 12:11 ·  中国 福建 泉州 晋江市 电信
初级用户
积分 97
发帖 40
注册 2006-11-01 13:59
19年会员
UID 69168
性别 男
状态 离线
想用一个批处理在任意磁盘分区(包括光驱)中的根目录下查找一个BAT.BAT命令并运行它得怎么样写呀
2 发表于 2007-03-05 21:25 ·  中国 河北 保定 联通
铂金会员
★★★★
网络独行侠
积分 6,962
发帖 2,753
注册 2003-04-16 00:00
23年会员
UID 1565
性别 男
来自 河北保定
状态 离线
请参考xyfpath.bat:

@echo off
echo %ComSpec% | find /i "cmd.exe" > nul
if errorlevel 1 goto _notnt
goto _nt

:_notnt
set drives=
for %%D in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) DO Call IsReady %%D
::echo %drives%
::pause

set mypath=
for %%D in (%drives%) DO if exist %%D\syssoft\clone\systools\ghost.exe apath *mypath %%D\SYSSOFT\CLONE\SYSTOOLS;%%D\SYSSOFT\CLONE\DOSTOOLS;%%D\SYSSOFT\CLONE\WINTOOLS
if exist c:\ucdos\nul apath c:\ucdos
if exist c:\dos71\nul apath c:\dos71
if exist c:\dos\nul apath c:\dos
if exist c:\batch\nul apath c:\batch
for %%D in (%drives%) DO if exist %%D\systools\pqmagic.exe apath *mypath %%D\SYSTOOLS;%%D\DOSTOOLS;%%D\WINTOOLS
if not "%mypath%"=="" apath %mypath%
if "%mypath%"=="" goto _nopath
echo Add %mypath%
goto _quit

:_nt
set drives=C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:
set mypath=
for %%D in (%drives%) DO if exist %%D\syssoft\clone\systools\ghost.exe set mypath=%mypath%;%%D\SYSSOFT\CLONE\SYSTOOLS;%%D\SYSSOFT\CLONE\DOSTOOLS;%%D\SYSSOFT\CLONE\WINTOOLS
if exist c:\ucdos\. set mypath=%mypath%;c:\ucdos
if exist c:\dos71\. set mypath=%mypath%;c:\dos71
if exist c:\dos\. set mypath=%mypath%;c:\dos
if exist c:\batch\. set mypath=%mypath%;c:\batch
for %%D in (%drives%) DO if exist %%D\systools\pqmagic.exe set mypath=%mypath%;%%D\SYSTOOLS;%%D\DOSTOOLS;%%D\WINTOOLS
if not "%mypath%"=="" goto _ntsetpath
if "%mypath%"=="" goto _nopath
:_ntsetpath
echo %path% | find /i "%mypath%" > nul
if errorlevel 1 set path=%path%;%mypath% && echo Add %mypath%
goto _quit

:_nopath
echo Sorry! I cannot find any xyf's path on your system.
echo PATH NOT SET!!!
pause

:_quit
set drives=
set mypath=


IsReady.BAT:

@echo off
dready %1 > nul
if errorlevel 1 goto _quit
if errorlevel 0 set drives=%1 %drives%

:_quit
偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
3 发表于 2007-03-06 02:04 ·  中国 福建 泉州 晋江市 电信
初级用户
积分 97
发帖 40
注册 2006-11-01 13:59
19年会员
UID 69168
性别 男
状态 离线
我手头上就有一个简单的,就是因为改不过来才上来发帖的,再整这么复杂的一个P处理给我还不看晕了

For %%a In (c d e f g h i j k l m n o p q r s t u v w s y z) Do ATTRIB -R -H -S -A %%a:\AUTORUN.INF & Del /F /Q /A -R -H -S -A %%a:\AUTORUN.INF & ATTRIB -R -H -S -A %%a:\_desktop.ini & Del /F /Q /A -R -H -S -A %%a:\_desktop.ini
4 发表于 2007-03-06 06:50 ·  新加坡
初级用户
★★
积分 172
发帖 77
注册 2006-11-23 15:05
19年会员
UID 71489
性别 男
状态 离线
@echo off
:QQ自动查找及运行
@set char=qq.exe
@for %%a in (c d e f) do for /f "tokens=*" %%i in ('dir /s/b/a-d %%a:\%char%') do echo %%i & start /b "" "%%i"
5 发表于 2007-03-06 06:52 ·  新加坡
初级用户
★★
积分 172
发帖 77
注册 2006-11-23 15:05
19年会员
UID 71489
性别 男
状态 离线
或者是这样
@for %%a in (c d e f) do for /f "tokens=*" %%i in ('dir /s/b/a-d %%a:\bat.bat') do echo %%i & start /b "" "%%i"
6 发表于 2007-03-06 08:24 ·  中国 福建 泉州 晋江市 电信
初级用户
积分 97
发帖 40
注册 2006-11-01 13:59
19年会员
UID 69168
性别 男
状态 离线
四楼报告没有找到文件,五楼是找到文件并运行了,可是,窗口不能自己关,还得手动关闭
论坛跳转: