小编Sid*_*024的帖子

批处理程序在变量中查找字符串

我试图在很多地方找到解决方案,但找不到具体的答案.

我正在创建一个批处理脚本.以下是我目前的代码

    @echo off
    SETLOCAL EnableDelayedExpansion
    cls
    for /f "delims=" %%a in ('rasdial EVDO cdma cdma') do set "ras=!ras! %%a"

    findstr /C:"%ras%" "already"

    if %errorlevel% == 0 
    (
        echo "it says he found the word already"
    )
    else
    (
        echo "it says he couldn't find the word already"
    )
Run Code Online (Sandbox Code Playgroud)

输出:

    FINDSTR: Cannot open already
    The syntax of the command is incorrect.
Run Code Online (Sandbox Code Playgroud)

我试图在变量'ras'中找到'已经'这个词,

问题似乎是在 findstr/C:"%ras%""已经"

我尝试使用 findstr"%ras%""已经" 但这也不起作用.

command-line batch-file command-prompt findstr

9
推荐指数
2
解决办法
2万
查看次数