简体   繁体   English

从Visual Basics调用时批处理文件未正确运行

[英]Batch file not running correctly when called from Visual Basics

I am attempting to write code that will call a batch file, wait until it is complete and then move on to the next line of code in Visual Basic. 我正在尝试编写将调用批处理文件的代码,等待其完成后再移至Visual Basic中的下一行代码。 The code I have does open the batch file, however it does not actually execute. 我拥有的代码确实打开了批处理文件,但是实际上并未执行。 It opens the cmd window and displays some non-code I've written, but does not execute. 它会打开cmd窗口,并显示一些我编写但未执行的非代码。 I've tested the batch file by clicking it and running through cmd and it works fine. 我已经通过单击批处理文件并通过cmd运行来测试该批处理文件,并且该文件运行正常。 Just doesn't run through VBS. 只是不通过VBS运行。

Dim objShell As Object

Set objShell = CreateObject("Wscript.Shell")
Wait = True
objShell.Run """C:\Users\wjones\Documents\Data Loader\Scheduler\process.bat""", 1, Wait

尝试这个:

objShell.Run "cmd /c C:\Users\wjones\Documents\Data Loader\Scheduler\process.bat", 1, Wait

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM