batch-file - DOS:找到一个字符串,如果找到则运行另一个脚本

标签 batch-file dos

我想使用DOS在文件中找到一个字符串:

例如

find "string" status.txt



当找到它时,我想运行一个批处理文件。

做这个的最好方式是什么?

最佳答案

@echo off
cls
MD %homedrive%\TEMPBBDVD\
CLS
TIMEOUT /T 1 >NUL
CLS
systeminfo >%homedrive%\TEMPBBDVD\info.txt
cls
timeout /t 3 >nul
cls
find "x64-based PC" %homedrive%\TEMPBBDVD\info.txt >nul
if %errorlevel% equ 1 goto 32bitsok
goto 64bitsok
cls

:commandlineerror
cls
echo error, command failed or you not are using windows OS.
pause >nul
cls
exit

:64bitsok
cls
echo done, system of 64 bits
pause >nul
cls
del /q /f %homedrive%\TEMPBBDVD\info.txt >nul
cls
timeout /t 1 >nul
cls
RD %homedrive%\TEMPBBDVD\ >nul
cls
exit

:32bitsok
cls
echo done, system of 32 bits
pause >nul
cls
del /q /f %homedrive%\TEMPBBDVD\info.txt >nul
cls
timeout /t 1 >nul
cls
RD %homedrive%\TEMPBBDVD\ >nul
cls
exit

关于batch-file - DOS:找到一个字符串,如果找到则运行另一个脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2010253/

相关文章:

c++ - 在 dos 批处理文件中关闭屏幕更新

batch-file - XP 上 bat 文件中管道的奇怪限制

build-automation - 批处理文件中的字符串符号操作?

batch-file - 通过批处理文件杀死 MS Access 进程

batch-file - ffmpeg concat + 处理时发现无效数据 + 检查有效 avi 文件

batch-file - 如何抑制cmd.exe中的 "terminate batch job"

command-line - 如何使 findstr 显示内联的完整文件路径?

assembly - 相对跳转超出范围 0020h 字节

c# - 在 Process 中调用 robocopy 的批处理脚本不会终止

windows - bat 文件 : Command to change only folders attributes not recursively