预期语句结束 (vbscript)

Expected end of statement (vbscript)

我有一个非常简单的vbscript代码:

Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
Dim executable As String = Path.Combine(path, "Google\Chrome\Application\chrome.exe")

Process.Start(executable, "http://google.com")

当我执行文件时,出现以下错误:

Expected end of statement

我做错了什么?

您的代码不是 VBScript,主要是 VB.Net。不能在 VBScript 中声明带有类型的变量,也不能在声明变量时为其赋值。

这是一个可行的 VBScript 解决方案:

Dim objWsc
Set objWsc = CreateObject("WScript.Shell")

Dim sPath
sPath = objWsc.ExpandEnvironmentStrings("%ProgramFiles%")

Dim sExecutable
sExecutable = """" & sPath & "\Google\Chrome\Application\chrome.exe" & """"

Dim sCommand
sCommand = sExecutable & " http:\google.com"
objWsc.Run sCommand