vbs cmd 路径空间 [英] vbs cmd path space

查看:26
本文介绍了vbs cmd 路径空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够从 vbs 脚本中调用以下 cmd 命令:

I would like to be able to call the following cmd command from within a vbs script:

cmd Clientsetupclient.exe /q /targetdir "c:program filesMicrosoft CRM"

我想出了以下 vbs 脚本:

I came up with the following vbs script:

Set oShell = WScript.CreateObject ("WScript.Shell") 
oShell.Run "cmd /c Clientsetupclient.exe /q /targetdir c:program filesMicrosoft CRM", 1, true

就我而言,如果 targetdir 没有空格,例如 c:la,这将正常工作.然后该应用程序将安装在该特定文件夹中.

As far as I am concerned, this would work properly if the targetdir had no spaces, e.g c:la. Then the app would be installed in that particular folder.

显而易见的问题是,如何定义带有空格的 targetdir 作为路径位置.
我试图用 ' ' 包围它,但这对我不起作用.有什么建议吗?

The obvious question is, how can I define the targetdir with spaces as the path location.
I tried to surround it with ' ' but that didn't work for me. Any suggestions?

干杯克里斯

推荐答案

带有空格的路径通常用引号字符 (") 括起来.在 VBScript 中,要将引号字符插入到您使用的字符串中双引号 ("").所以,你的代码应该是这样的:

Paths with spaces are typically enclosed in quote characters ("). In VBScript, to insert a quote character into a string you use double quotes (""). So, your code should look like this:

oShell.Run "cmd /c Clientsetupclient.exe /q /targetdir ""c:program filesMicrosoft CRM""", 1, true

另外,我不确定这里是否真的需要 cmd/c,所以它也可以这样工作:

Also, I'm not sure if cmd /c is actually needed here, so it might work this way as well:

oShell.Run "Clientsetupclient.exe /q /targetdir ""c:program filesMicrosoft CRM""", 1, true

这篇关于vbs cmd 路径空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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