How do you strip quotes out of an ECHO'ed string in a Windows batch file?

后端 未结 12 1892
萌比男神i
萌比男神i 2020-12-05 04:23

I have a Windows batch file I\'m creating, but I have to ECHO a large complex string, so I\'m having to put double quotes on either end. The problem is that the quotes are

12条回答
  •  没有蜡笔的小新
    2020-12-05 05:05

    The above answer (starting with :DeQuote) assumes delayed environment variable expansion is set to on. From cmd /?:

    Delayed environment variable expansion is NOT enabled by default. You can enable or disable delayed environment variable expansion for a particular invocation of CMD.EXE with the /V:ON or /V:OFF switch. You can enable or disable completion for all invocations of CMD.EXE on a machine and/or user logon session by setting either or both of the following REG_DWORD values in the registry using REGEDT32.EXE:

    HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\DelayedExpansion
    
        and/or
    
    HKEY_CURRENT_USER\Software\Microsoft\Command Processor\DelayedExpansion
    

    to either 0x1 or 0x0. The user specific setting takes precedence over the machine setting. The command line switches take precedence over the registry settings.

    If delayed environment variable expansion is enabled, then the exclamation character can be used to substitute the value of an environment variable at execution time.

提交回复
热议问题