从 VBScript 执行 cmd 命令 [英] Execute cmd command from VBScript

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

问题描述

如何从 VBScript(而不是 .bat 文件)执行 cmd 命令

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

例如,我想从 VBScript 执行以下内容:

For example, I want to execute the following from VBScript:

cd /d C:dir_testfile_test 
sanity_check_env.bat arg1

推荐答案

要运行dos"命令,您需要实例化 WScript.Shell 对象并使用它的 Run()代码>方法:

To run 'dos' commands you need to instantiate the WScript.Shell object and use it's Run() method:

Set oShell = WScript.CreateObject("WScript.Shell")
oShell.run "cmd cd /d C:dir_testfile_test & sanity_check_env.bat arg1"

这篇关于从 VBScript 执行 cmd 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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