Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running vbscript from batch file

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 

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?

like image 412
user918197 Avatar asked Aug 10 '12 10:08

user918197


People also ask

How do I run a VBS file from a batch file?

Batch files are processed row by row and terminate whenever you call an executable directly. - To make the batch file wait for the process to terminate and continue, put call in front of it. - To make the batch file continue without waiting, put start "" in front of it.

Can you run VBScript in CMD?

VBScript - Running Scripts from the Command Prompt. Windows Script Host enables you to run scripts from the command prompt. CScript.exe provides command-line switches for setting script properties.


1 Answers

You can use %~dp0 to get the path of the currently running batch file.

Edited to change directory to the VBS location before running

If you want the VBS to synchronously run in the same window, then

@echo off pushd %~dp0 cscript necdaily.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 

If you want the VBS to asynchronously run in the same window, then

@echo off pushd %~dp0 start /b "" cscript necdaily.vbs 

If you want the VBS to asynchronously run in a new window, then

@echo off pushd %~dp0 start "" cmd /c cscript necdaily.vbs 
like image 78
dbenham Avatar answered Sep 20 '22 23:09

dbenham