Board logo

标题: [文本处理] [已解决]如何让echo注释和Call结果在同一行 [打印本页]

作者: zidha    时间: 2019-8-25 18:25     标题: [已解决]如何让echo注释和Call结果在同一行

本帖最后由 zidha 于 2019-8-26 07:17 编辑

想要的结果如下:

ComputerName:PC0001

如何实现?

ComputerName:这个是注释颜色不变,":"不行可以替换成__

PC0001需要字体高亮为颜色色。

测试过很多次只弄出如下脚本

注释和结果都变颜色了
  1. @echo off
  2. set "zhushi=ComputerName__"
  3. set "str=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName"
  4. for /f "tokens=2*" %%a in ('reg query "%str%" /v ComputerName 2^>nul') do set "PCName=%%b"
  5. call:JV "%zhushi%%PCName%"
  6. goto:eof
  7. :JV
  8. set/p= <nul>"%1"
  9. findstr /a:0a .* "%1*" 2>nul
  10. del "%zhushi%%PCName%"
复制代码

作者: flashercs    时间: 2019-8-25 19:55

  1. @echo off
  2. set "zhushi=ComputerName__"
  3. set "str=HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName"
  4. for /f "tokens=2*" %%a in ('reg query "%str%" /v ComputerName 2^>nul') do set "PCName=%%b"
  5. call:JV "%zhushi%" "%PCName%"
  6. goto:eof
  7. :JV
  8. set/p= <nul>"_%~2"
  9. <nul,set /p=%~1
  10. findstr /a:0a .* "_*" 2>nul
  11. del "_%~2"
复制代码

作者: zidha    时间: 2019-8-26 07:16

回复 2# flashercs
非常感谢!
我已经用Batcher大的脚本实现了想要的结果。
http://bbs.bathome.net/thread-1852-1-1.html

但我还有个问题,这个“_%~2” 为什么要加“_”和“%~2”含义?




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2