【问题标题】:Brackets in the folder name文件夹名称中的括号
【发布时间】:2026-01-31 16:40:01
【问题描述】:

我正在尝试创建一个运行文件的脚本,问题是它所在的文件夹具有字符“[]”,并且每次我尝试打开它时都会显示一个错误,指出找不到路径。 .. 因为我会忽略这个角色?

Sub Main()

If WScript.Arguments.Count >= 1 Then
MyFileSWF = WScript.Arguments.Item(0)
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.run "CMD /C Start /Max "" ""[ Utilities ]\Flash Player Standalone 18.exe"" " & """" & MyFileSWF & """", 0, True
End If

End Sub
On Error Resume Next
Main
If Err.Number Then
WScript.Quit 4711
End If

【问题讨论】:

    标签: vbscript


    【解决方案1】:

    这个:

    "CMD /C Start /Max "" ""[ Utilities ]\Flash Player Standalone 18.exe"" " & """" & MyFileSWF & """"
    

    被解释为:

    CMD /C Start /Max " "[ Utilities ]\Flash Player Standalone 18.exe" "%swfFile%"
    

    注意目录名称(带方括号)实际上是如何从第一个引号括起来的字符串中排除的。

    改成这样:

    "CMD /C Start /Max ""[ Utilities ]\Flash Player Standalone 18.exe"" """  & MyFileSWF & """"
    

    【讨论】:

    • 感谢你的帖子我找到了问题,问题出在 Start /Max "" 应该是 Start /Max """"
    最近更新 更多