gpt4 book ai didi

vbscript - 预期的语句结束 (vbscript)

转载 作者:行者123 更新时间:2023-12-04 08:09:55 25 4
gpt4 key购买 nike

我有一个非常简单的 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


enter image description here
我究竟做错了什么?

最佳答案

您的代码不是 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

关于vbscript - 预期的语句结束 (vbscript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66031534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com