从批处理文件运行 vbscript [英] Running vbscript from batch file

查看:50
本文介绍了从批处理文件运行 vbscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要编写一个简单的批处理文件来运行 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%SysWOW64cmd.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?

推荐答案

可以使用 %~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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆