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
What am I doing wrong?
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