Board logo

标题: 用P处理命令在任意分区中查找并运行一个命令 [打印本页]

作者: qingyangecho     时间: 2007-3-5 12:11    标题: 用P处理命令在任意分区中查找并运行一个命令

想用一个批处理在任意磁盘分区(包括光驱)中的根目录下查找一个BAT.BAT命令并运行它得怎么样写呀
作者: Climbing     时间: 2007-3-5 21:25
请参考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

作者: qingyangecho     时间: 2007-3-6 02:04
我手头上就有一个简单的,就是因为改不过来才上来发帖的,再整这么复杂的一个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
作者: cjfcjf222     时间: 2007-3-6 06:50
@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"
作者: cjfcjf222     时间: 2007-3-6 06:52
或者是这样
@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"
作者: qingyangecho     时间: 2007-3-6 08:24
四楼报告没有找到文件,五楼是找到文件并运行了,可是,窗口不能自己关,还得手动关闭