VBScript 参数中的双引号 [英] Double quotes in VBScript argument
问题描述
正如我自己阅读和体验的那样,VBScript 从 和 参数中删除了所有双引号.有谁知道解决这个问题的方法?如何将双引号传递到脚本中?
As I read and experienced for myself VBScript removes all double quotes from and argument. Does anyone know a way around this? How to pass double quotes into the script?
推荐答案
如果该参数需要引号,您可以使用命名参数来标识它,然后用双引号将值括起来
If that parameter requires quotes you could use a named parameter to identify it and then enclose the value with the double quotes
dim arg
if WScript.Arguments.Named.Exists("a") then
arg = WScript.Arguments.Named("a")
arg = chr(34) & arg & chr(34)
end if
并因此使用:
cscript test.vbs /a:"a parameter"
但是如果您只想保留引号(如果提供),这无济于事.单引号被接受,因此您可以选择使用单引号(或其他字符/字符串)并执行 Replace(arg, "'", chr(34))
转换为双引号.
but this doesn't help if you merely want to keep quotes if supplied. Single quotes are accepted though, so you could alternatively use single quotes (or another character/string) and do a Replace(arg, "'", chr(34))
to convert to double-quotes.
这篇关于VBScript 参数中的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!