0

我在使用批处理脚本时遇到了一些麻烦,该脚本需要将配置文件中的值解析为变量。问题是想要从一个价值中削减“

从“启用”到启用

    for /f "tokens=*" %%d in ('C:\example.exe -devgs !ID1!;!ID2! ^| grep.exe accountState ^| awk.exe -F "(: )" "{print $2}"') do set State=%%d
echo !State!
"enabled"

如果我尝试 Awk 或 TR 并删除结果周围的引号,它会失败

    for /f "tokens=*" %%d in ('C:\example.exe -devgs !ID1!;!ID2! ^| grep.exe accountState ^| awk.exe -F "(: )" "{print $2}" ^| tr.exe -d """') do set State=%%d
echo !State!
The syntax of the command is incorrect.
    for /f "tokens=*" %%d in ('C:\example.exe -devgs !ID1!;!ID2! ^| grep.exe accountState ^| awk.exe -F "(: )" "{print $2}" ^| tr.exe -d ^"') do set State=%%d
echo !State!
"enabled"
4

0 回答 0