简体   繁体   English

如何解析批处理文件中的命令输出

[英]How to parse the command output in batch file

i'm creating a batch file to show my current power plan i'm using this command:我正在创建一个批处理文件来显示我当前的电源计划我正在使用以下命令:

powercfg -getactivescheme

it shows the result like this:它显示的结果是这样的:

Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance)

i want to hide the power plan code so it only shows:我想隐藏电源计划代码,所以它只显示:

(High performance)

any help is appreciated :D thanks!任何帮助表示赞赏:D 谢谢!

Use the standard parse-loop :使用标准解析循环

for /f "delims=() tokens=2" %%a in ('powercfg -getactivescheme') do set name=%%a
echo Name: (%name%)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM