VB 脚本想要从 VB 运行 .bat 文件 [英] VB script want to run .bat file from VB

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

问题描述

我尝试从 VB 运行 go.bat,但是当我运行脚本时,我得到::找不到特定文件

I am try to run the go.bat from VB but when I run the script I get: :cant find specific file

但是在 cmd 窗口中文件 go.bat 存在.什么问题?

but from the cmd window the file go.bat exist. what the problem?

Dim MyShell

Dim shell_cmd

  shell_cmd = "C:\Program Files\dir1\dir2\wizard\go.bat"

  set MyShell = CreateObject("WScript.Shell")

  MyShell.Run shell_cmd, 1, 1

来自 cmd 窗口

C:\Program Files\dir1\dir2\wizard>go.bat

推荐答案

你的批处理文件的完整路径包含空格,所以你需要用双引号把它括起来,像这样:

Your batch file's full path contains spaces, so you need to enclose it in double quotes, like this:

shell_cmd = """C:\Program Files\dir1\dir2\wizard\go.bat"""

shell_cmd = Chr(34) & "C:\Program Files\dir1\dir2\wizard\go.bat" & Chr(34)

这篇关于VB 脚本想要从 VB 运行 .bat 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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