Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The bat has >>%vbs% echo oShellLink.IconLocation = "%1, 0"to produce

oShellLink.IconLocation = ""C:\WINDOWS\NOTEPAD.exe", 0"`

where %1 is a quoted path

However, unless I remove the quotes from path like here:

oShellLink.IconLocation = "C:\WINDOWS\NOTEPAD.exe, 0"

I get the titular error. What do you suggest? (Note that %1 is always supplied with quotes)

Also, I'm not very familiar with vbscript, why does it require no quotes next to each other?


Still not clear why vbscript can't interpret this assignment, but found a fix: %~1 - Expands %1 and removes any surrounding quotation marks ("").

share|improve this question
up vote 0 down vote accepted

In VBS you need to escape double quote characters with a second double quote character.

So change

>>%vbs% echo oShellLink.IconLocation = "%1, 0"


>>%vbs% echo oShellLink.IconLocation = ""%1", 0"

Which in the VBS file will give you

oShellLink.IconLocation = """C:\WINDOWS\NOTEPAD.exe"", 0"

Which parses out to "C:\WINDOWS\NOTEPAD.exe", 0 before being assigned to .IconLocation.

Edit (additional info):

Basically, the error is thrown if you put a non-escaped quote in the (not literal) string.

This is because the parser thinks it (the quote character) is the end marker of the string, which leaves garbage (the remaining characters) after it.

So, since the closing quote is supposed to be the 'end of the statement' marker, but it finds characters after that closing quote, there's an error because it "Expected" that was the "End of Statement".

The path works with and without the escaped quotes wrapping it because of the way .IconLocation intelligently parses the list of arguments you are feeding it as a single String.

share|improve this answer
That works, thanks. – user93200 Aug 7 '11 at 3:35
My understanding of how this works (please correct it if needed): it sees assignment, so it strips outside double quotes in rhs. Then any double next to each other are converted to a literal double quote. But if they're not literal somehow they cause an error. – user93200 Aug 7 '11 at 3:47
Your explanation of how they parse is correct. I'll try to clarify why that error is coming up a little in an edit to my question (due to room). – Ƭᴇcʜιᴇ007 Aug 7 '11 at 6:28

Your problem is this line

oShellLink.IconLocation = ""C:\WINDOWS\NOTEPAD.exe", 0"

You have a "" which is the quote escape character. This basically lets you have a string that contains a quote without having a parser error. Like so:

" this is a string literal that contains a "" quote character"


this is a string literal that contains a " quote character

share|improve this answer
So how do I strip the quotes from %1 if they're not needed? – user93200 Aug 7 '11 at 3:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.