• It looks like the SQLCMD -v option is expecting the variable to be quoted.

    SQLCMD -v myVariable="myValue"

    To get the the variable quoted add an additional set of double quotes:

    :SETVAR myVariable """N'C:\temp'"""

    :!!ECHO $(myVariable)