加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

批处理文件 – DOS:找到一个字符串,如果找到,则运行另一个脚本

发布时间:2020-12-13 20:50:59 所属栏目:Windows 来源:网络整理
导读:我想使用DOS在文件中找到一个字符串: 例如 find “string” status.txt 当找到它时,我想运行一个批处理文件。 这样做最好的方法是什么? @echo offclsMD %homedrive%TEMPBBDVDCLSTIMEOUT /T 1 NULCLSsysteminfo %homedrive%TEMPBBDVDinfo.txtclstimeou
我想使用DOS在文件中找到一个字符串:

例如

find “string” status.txt

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

这样做最好的方法是什么?

@echo off
cls
MD %homedrive%TEMPBBDVD
CLS
TIMEOUT /T 1 >NUL
CLS
systeminfo >%homedrive%TEMPBBDVDinfo.txt
cls
timeout /t 3 >nul
cls
find "x64-based PC" %homedrive%TEMPBBDVDinfo.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%TEMPBBDVDinfo.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%TEMPBBDVDinfo.txt >nul
cls
timeout /t 1 >nul
cls
RD %homedrive%TEMPBBDVD >nul
cls
exit

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读