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
首先会影响循环?