如何在Windows批处理文件转换成一个劲儿地线" CMD / C"命令? [英] How to convert a windows batch file into a signle line "cmd /c" command?

查看:196
本文介绍了如何在Windows批处理文件转换成一个劲儿地线" CMD / C"命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将拥有以下的批处理文件,并希望将其转换为一个单行的 CMD / C 命令。

  @ECHO OFF
SETLOCAL
FOR / F令牌= 2 DELIMS =:。 %% I IN('CHCP')DO SET _ codePAGE _ = %%我
SET _ codepage_ =的Cp%_ codepage_:=%
ECHO%_ codepage_%
ENDLOCAL

我试过:

  CMD / C FOR / F令牌= 2 DELIMS =:。 %I IN('CHCP')DO @SET _ codePAGE _ =%I和;&安培; @SET _ codepage_ =的Cp%_ codepage_:=%放大器;&安培; @ECHO%_ codepage_%

也试过:

  CMD / V:在FOR / F / C标记= 2 DELIMS =:。 %I IN('CHCP')DO @SET _ codePAGE _ =%I和;&安培; @SET _ codepage_ =的Cp%_ codepage_:=%放大器;&安培; @ECHO!_ codepage_!

但既不方法效果!有人可以帮助我在这里?


解决方案

  CMD / Q / CFOR / F令牌= 2delims = :.在(​​'CHCP'一% )为(%A%b做)做回波(的Cp%b

什么原来的code呢?拆分 CHCP,除去结束点(我不知道,谢谢),存储变量中的值,以便从和$ P删除空间的输出$与 CP PFIX,然后回显变量

这是什么code呢?拆分 CHCP 的输出,去掉结束点,而不是使用一个变量来删除空格,一个aditional的回路用于在从所述第一循环的值,并且,代替prefixing变量,在的Cp 被包括在数据的响应。

I have the batch file below and wish to convert it to a single line cmd /c command.

@ECHO OFF
SETLOCAL
FOR /F "TOKENS=2 DELIMS=:." %%I IN ('chcp') DO SET _codepage_=%%I
SET _codepage_=Cp%_codepage_: =%
ECHO %_codepage_%
ENDLOCAL

I tried:

cmd /c FOR /F "TOKENS=2 DELIMS=:." %I IN ('chcp') DO @SET _codepage_=%I && @SET _codepage_=Cp%_codepage_: =% && @ECHO %_codepage_%

also tried:

cmd /v:on /c FOR /F "TOKENS=2 DELIMS=:." %I IN ('chcp') DO @SET _codepage_=%I && @SET _codepage_=Cp%_codepage_: =% && @ECHO !_codepage_!

but neither approach works! Can anyone help me out here?

解决方案

cmd /q/c"for /f "tokens=2delims=:." %a in ('chcp')do for %b in (%a)do echo(Cp%b"

What did the original code do? split the output of chcp, remove the ending dot (I didn't knew it, thank you), storing the value inside a variable to remove a space from it and prefix it with Cp and then echo the variable

What does this code do? split the output of chcp, remove the ending dot, but instead of using a variable to remove the space, an aditional for loop is used over the value from the first loop, and, instead of prefixing the variable, the Cp is included in the data echoed.

这篇关于如何在Windows批处理文件转换成一个劲儿地线" CMD / C"命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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