Execute DOS command from VBScript

jon picture jon · Mar 29, 2011 · Viewed 110.1k times · Source

How I can Execute a DOS command from VBScript (not by .bat file)

For example I want to execute the following from VBScript:

cd /d C:dir_test\file_test 

sanity_check_env.bat arg1

Answer

Gratzy picture Gratzy · Mar 29, 2011
Set oShell = WScript.CreateObject("WSCript.shell")
oShell.run "cmd cd /d C:dir_test\file_test & sanity_check_env.bat arg1"