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

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

问题描述

我想在vbs脚本中调用以下cmd命令:

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

cmd Client\setupclient.exe /q /targetdir "c:\program files\Microsoft CRM"

使用以下vbs脚本:

Set oShell = WScript.CreateObject ("WScript.Shell") 
oShell.Run "cmd /c Client\setupclient.exe /q /targetdir c:\program files\Microsoft CRM", 1, true

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

As far as I am concerned, this would work properly if the targetdir had no spaces, e.g c:\bla. 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?

干杯
chris

Cheers chris

推荐答案

)。在VBScript中,要将引号字符插入到字符串中,请使用双引号( / code>)。因此,您的代码应如下所示:

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 Client\setupclient.exe /q /targetdir ""c:\program files\Microsoft CRM""", 1, true


b $ b

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

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

oShell.Run "Client\setupclient.exe /q /targetdir ""c:\program files\Microsoft CRM""", 1, true

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

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