17
A
回答
5
@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
26
它已經一段時間,因爲我已經做了批處理文件什麼,但我認爲以下工作:
find /c "string" file
if %errorlevel% equ 1 goto notfound
echo found
goto done
:notfound
echo notfound
goto done
:done
這的確是一個概念證明;清理,因爲它適合您的需求。關鍵是如果string
不在file
中,find
返回errorlevel
的1
。在這種情況下,我們分支到notfound
,否則我們處理found
的情況。
9
6
我們有兩個命令,第一個是「condition_command」,第二個是「result_command」。 如果我們需要運行 「result_command」 當 「condition_command」 是成功的(錯誤級別= 0):
condition_command && result_command
如果我們需要運行 「result_command」 當 「condition_command」 是失敗的:
condition_command || result_command
因此,對於萬一
find "string" status.txt 1>nul && some_command
,當我們在文件「status.txt中」沒有「串」:萬一運行「some_command」當我們在文件「status.txt中」有「字符串」
find "string" status.txt 1>nul || some_command
6
相關問題
- 1. 找到另一個字符串內的多個字符串
- 2. 找到一個子串和插入另一個字符串
- 3. 如何找到一個字符串出現在另一個字符串
- 4. 如何找到一個字符串是否包含在另一個字符串
- 5. C++:查找字符串中的一個字符,然後找到另一個字符前一個字符
- 6. 如何拆分一個字符串並在另一個字符串中找到一個字符串?
- 7. 使用grep找到文本,如果在文件中找到echo那個文件中的另一個字符串
- 8. 找到一個字符串,但返回前一個字符串
- 9. Bash:在文件的另一個字符串之前找到一個字符串
- 10. 找到一個字符串的位置在另一個字符串
- 11. 如果在另一個字符串中找到字符串,則將其替換爲空白字符
- 12. Python腳本,將一個字符串映射到另一個字符串
- 13. 如何在另一個字符串中找到字符串的一部分?
- 14. php搜索字符串,如果找不到字搜索另一個字
- 15. 從文件查找字符串到shell腳本中的另一個文件
- 16. 如果找到一個字符,則追加
- 17. 找到一個子字符串中的
- 18. 找到一個字符串中的點?
- 19. 算法找到一個字符串
- 20. 找到一個字符串的長度
- 21. Java找到一個字符串的DateFormat
- 22. 找到一個給定的字符串
- 23. 在C中找到一個字符串
- 24. 給定一個字符串,找到一個字符串開始的行開始
- 25. 檢測(找到)串在另一個字符串(爲nvarchar(MAX))
- 26. 如何在另一個字符串中找到沒有嵌入另一個字詞的字符串?
- 27. 如何找到一個字符串中的字符串
- 28. 在另一個字符串中查找一個字符串的字符串
- 29. PowerShell來尋找另一個字符串
- 30. PHP:刪除在另一個字符串中找到的字符串字符
不'find'返回取決於是否字符串不同'errorlevel'值被發現?如果是這樣,那麼你的解決方案就在那裏。 – 2010-01-06 00:50:43
您是真的指MS-DOS還是Windows的cmd.exe批解釋器? – 2010-01-06 01:19:44