2
votes

I have a very simple vbscript code:

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")

When I execute the file, I got the following error:

Expected end of statement

enter image description here

What am I doing wrong?

1

1 Answers

2
votes

Your code isn't VBScript, it's mostly VB.Net. You cannot declare variables with types in VBScript and you cannot assign a value to a variable while declaring it.

Here's a VBScript solution that will work:

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