1

我有以下情况

    @echo off
    for %%x in (
    machine1
    machine2
    machine3

for %%y in (
    A
    B
    C
    D
           )
              )

    do
    (
    echo machine is %%x

    \\%%x\%%y

    )

我实际上是在检查股票是否开盘

\\machine1\A , \\machine1\B 等等..

你们能帮我解决嵌套循环吗?

4

2 回答 2

0

尝试这个:

@echo off
for %%x in ( "machine1", "machine2", "machine3" ) do (
    echo machine is %%x
    for %%y in ( "A", "B", "C", "D" ) do (
        echo share is \\%%x\%%y
    )
)
于 2016-05-21T01:23:26.617 回答
0

如果我理解您的问题,您想遍历一堆计算机,并在每台计算机上遍历一堆驱动器号以查看驱动器是否共享?如果是这样,你真的很接近。您只需要使用IF EXIST来检查您正在构建的路径是否是共享的。

@echo off
FOR %%x IN (machine1, machine2, machine3) DO (
    echo Checking shares on machine: %%x
    FOR %%y IN (A, B, C, D) DO (
        echo Testing share: \\%%x\%%y
        if exist \\%%x\%%y (echo Shared) else (echo Not Shared)
   )
)
于 2016-05-20T18:59:20.913 回答