问题
I'm automating the task of disabling the Proxy on Mozilla firefox (it currently defaults to 'Automatic proxy config url' and I manually set it to 'No Proxy').
After some research, I realised the settings can be changed by creating a user.js file (which overrides the firefox settings stored in pref.js) that contains this:
user_pref("network.proxy.type", 0);
Below is the vbs syntax i'm having issues with:
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="%APPDATA%\Mozilla\Firefox\Profiles\3b59qrw5.default\user.js"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "user_pref("network.proxy.type", 0);" & vbCrLf
objFile.Close
When executing the vbs file, I get this error
Line 5 Char 27 Expected end of statement 800A0401
Any help would be great, Thank you.
回答1:
VBScript strings are delimited by double quotes. If you want to use double quotes inside strings in VBScript, you must either escape them by using double double quotes:
objFile.Write "user_pref(""network.proxy.type"", 0);" & vbCrLf
or insert literal double quotes (ASCII character 34) by concatenation:
objFile.Write "user_pref(" & Chr(34) & "network.proxy.type" & Chr(34) _
& ", 0);" & vbCrLf
来源:https://stackoverflow.com/questions/16022316/expected-end-of-statement-error-in-vbs-file