Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 调用VBs文件后循环批处理文件中的所有元素_Batch File_For Loop_Vbscript - Fatal编程技术网

Batch file 调用VBs文件后循环批处理文件中的所有元素

Batch file 调用VBs文件后循环批处理文件中的所有元素,batch-file,for-loop,vbscript,Batch File,For Loop,Vbscript,所以我需要使用批处理文件来访问数据库中的信息。这不是一个理想的方法,但它是我唯一可以使用的方法 以下是我遇到一些问题的代码: FOR /F %%i in (C:\Users\c1921\my_Data\mytestUnits.txt) DO ( set "$Unit=%%i" echo The unit is :!$Unit! echo the token is still:%$token% curl -H "Authorization: auth_to

所以我需要使用批处理文件来访问数据库中的信息。这不是一个理想的方法,但它是我唯一可以使用的方法

以下是我遇到一些问题的代码:

    FOR /F %%i in (C:\Users\c1921\my_Data\mytestUnits.txt) DO (
    set "$Unit=%%i"
    echo The unit is :!$Unit!
    echo the token is still:%$token%

    curl -H "Authorization: auth_token %$token%" https://ads-dev.examplewebpage.com/apiv1/dsns/!$Unit!/properties.xml>C:\Users\c1921\my_Data\XMLFile.xml

    start C:\Users\c1921\my_Data\curltest.vbs

    echo pause after checking all the properties of a unit

    pause

      )
问题是我在mytestUnits.txt中有四个测试单元,它将为每个单元打印令牌和单元,但只运行这一行一次:

    start C:\Users\cm\my_Data\curltest.vbs
我试过使用
goto:next
,但也没用。我还知道
XMLDOM
(我在curltest.vbs中编写)没有close或delete方法,所以我想这可能就是问题所在

任何建议都将不胜感激

DM

编辑:


在检查一个单元的所有属性后,我添加了
echo pause,以查看它何时到达这一点,并且这只对循环中的最后一项执行。我试着用这些信息调用一个新的批处理文件,但也没用

尝试不使用
启动

FOR /F %%i in (C:\Users\c1921\my_Data\mytestUnits.txt) DO (
set "$Unit=%%i"
echo The unit is :!$Unit!
echo the token is still:%$token%

curl -H "Authorization: auth_token %$token%" https://ads-dev.examplewebpage.com/apiv1/dsns/!$Unit!/properties.xml>C:\Users\c1921\my_Data\XMLFile.xml

C:\Users\c1921\my_Data\curltest.vbs

echo pause after checking all the properties of a unit

pause

  )

另一个选项是使用
start/wait
。您可能还希望使用
cscript.exe
运行VBScript,而不是批处理脚本中的默认
wscript.exe
。我不知道为什么
ENDDO
对我有效这一定是一个奇怪的侥幸。不管怎样,我按照建议做了尝试,没有使用
启动
,效果很好。我要用这个,因为我认为这是正确的方法。为什么
start
首先会影响循环?