如何解析批处理文件中的命令输出 [英] How to parse the command output in batch file

查看:29
本文介绍了如何解析批处理文件中的命令输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个批处理文件来显示我当前的电源计划我正在使用这个命令:

i'm creating a batch file to show my current power plan i'm using this command:

powercfg -getactivescheme

结果如下:

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

我想隐藏电源计划代码,以便只显示:

i want to hide the power plan code so it only shows:

(High performance)

感谢任何帮助:D谢谢!

any help is appreciated :D thanks!

推荐答案

使用标准的parse-loop:

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

这篇关于如何解析批处理文件中的命令输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆