DOS:找一个字符串,如果找到则运行另一个脚本 [英] DOS: find a string, if found then run another script
本文介绍了DOS:找一个字符串,如果找到则运行另一个脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想找到使用DOS文件中的一个字符串:
例如
找到字符串status.txt中
块引用>和的时候才发现,我想运行一个批处理文件。
什么是做到这一点的最好方法是什么?
解决方案关闭@echo
CLS
MD%HOMEDRIVE%\\ TEMPBBDVD \\
CLS
TIMEOUT / T 1 GT; NUL
CLS
的SystemInfo>%HOMEDRIVE%\\ TEMPBBDVD \\信息.txt
CLS
超时/吨,3 GT; NUL
CLS
找到基于x64的PC%HOMEDRIVE%\\ TEMPBBDVD \\信息.txt> NUL
如果%ERRORLEVEL%EQU 1页转到32bitsok
转到64bitsok
CLS:commandlineerror
CLS
回声错误,命令失败或你不使用的是Windows操作系统。
暂停> NUL
CLS
出口:64bitsok
CLS
回声完成,64比特系统
暂停> NUL
CLS
DEL / Q / F%HOMEDRIVE%\\ TEMPBBDVD \\信息.txt> NUL
CLS
超时/吨,1 GT; NUL
CLS
RD%HOMEDRIVE%\\ TEMPBBDVD \\> NUL
CLS
出口:32bitsok
CLS
回声完成,32位的系统
暂停> NUL
CLS
DEL / Q / F%HOMEDRIVE%\\ TEMPBBDVD \\信息.txt> NUL
CLS
超时/吨,1 GT; NUL
CLS
RD%HOMEDRIVE%\\ TEMPBBDVD \\> NUL
CLS
出口I want to find a string in a file using DOS:
For example
find "string" status.txt
And when it is found, I want to run a batch file.
What is the best way to do this?
解决方案@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
这篇关于DOS:找一个字符串,如果找到则运行另一个脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文