从运行批处理文件的VBScript [英] Running vbscript from batch file
问题描述
我只需要编写一个简单的批处理文件只是为了运行一个VBScript。两者的VBScript和批处理文件是在同一文件夹,并在Syswow64资料目录中的VBScript可以仅在该目录中执行。目前我的批处理文件如下:
I just need to write a simple batch file just to run a vbscript. Both the vbscript and the batch file are in the same folder and is in the SysWOW64 directory as the vbscript can only be execute in that directory. Currently my batch file is as follows:
@echo off
%WINDIR%\SysWOW64\cmd.exe
cscript necdaily.vbs
但VBScript中不执行,只是命令提示符打开。谁能告诉我,我怎么能执行的VBScript当我运行这个批处理文件?谢谢你。
But the vbscript wasn't executed and just the command prompt is open. Can anyone tell me how can i execute the vbscript when i run this batch file? Thanks.
推荐答案
您可以使用%〜DP0
来获得当前正在运行的批处理文件的路径。
You can use %~dp0
to get the path of the currently running batch file.
的编辑运行前更改目录的VBS位置的
如果你想在VBS同步在同一个窗口中运行,那么
If you want the VBS to synchronously run in the same window, then
@echo off
pushd %~dp0
cscript necdaily.vbs
如果你想在VBS同步在新窗口中运行,那么
If you want the VBS to synchronously run in a new window, then
@echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
如果您希望VBS异步在同一个窗口中运行,那么
If you want the VBS to asynchronously run in the same window, then
@echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
如果您希望VBS异步在新窗口中运行,那么
If you want the VBS to asynchronously run in a new window, then
@echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
这篇关于从运行批处理文件的VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!