【问题标题】:Batch code to print each path entry in a new row? [duplicate]在新行中打印每个路径条目的批处理代码? [复制]
【发布时间】:2015-10-21 06:29:14
【问题描述】:

任何人都可以共享一个批处理脚本,在新行中打印每个批处理条目吗?

例如 - 如果Path = C:\Python27;C:\Python27\Scripts

然后它将被打印为

C:\Python27
C:\Python27\Scripts

【问题讨论】:

    标签: batch-file


    【解决方案1】:

    我有一个执行此操作的 VBscript:

    Set oShell = CreateObject( "WScript.Shell" )
    pathList = oShell.ExpandEnvironmentStrings("%PATH%")
    
    dirs = Split(pathList, ";", -1, 1)
    
    For i = 0 to UBound(dirs)
       WScript.Echo dirs(i)
    Next
    

    另存为,例如list_path.vbs,您可以像使用任何其他批处理文件一样使用它。

    如果您无法通过输入 list_path 来运行它,则需要调整 PATH_EXT 的值以包含 .vbs(但我认为这是现代 Windows 版本中的默认值 - 我不记得了必须调整)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-22
      • 1970-01-01
      • 1970-01-01
      • 2017-04-23
      相关资源
      最近更新 更多