title: escape characters in variables in a batch script
body: <p>I have i.a. variables like:</p>
  
  <pre><code>SET CURRHOST=myServer
  SET CURRCOMPANY=myCompany
  SET CURRDB=string!string=string!string=string
  </code></pre>
  
  <p>after I set this variable:</p>
  
  <pre><code>SET NAME=%CURRHOST%\%CURRCOMPANY%\%CURRDB%
  </code></pre>
  
  <p>I also used the variables above in other variables. But my problem is now, that the script thinks that my CURRDB variable is a command.</p>
  
  <p>I tried to escape the variable like</p>
  
  <pre><code>SETLOCAL ENABLEDELAYEDEXPANSION
  SET CURRDB=string^^!string^^=string^^!string^^=string
  </code></pre>
  
  <p>and then use this variable in other variables with</p>
  
  <pre><code>!CURRDB!
  </code></pre>
  
  <p>But it does not work. It also removes the ! character and the string between the = character. </p>
  
  <p>So how can I escape this characters in the CURRDB variable.</p>
  
  <p>EDIT:</p>
  
  <p>what I am trying to do exaktly:</p>
  
  <pre><code>SETLOCAL ENABLEDELAYEDEXPANSION
  set CURRHOST=myServer
  set CURRCOMPANY=myCompany
  set CURRDBASE=string!string=string!string=string
  set CURRSQLCMD="C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn"
  set CURRFILETREE=E:\SWF_DBankBackup\MSSQL2012
  </code></pre>
  
  <p>After I use these variables obove for other variables:</p>
  
  <pre><code>set DateiName=%CURRHOST%_%CURRDBASE%_BackupCurrent
  set Backuppath=%CURRFILETREE%\%CURRCOMPANY%\%CURRDBASE%
  set BackupSkript=%Backuppath%\BackupCurrentScript\%DateiName%_Full_Script.sql
  set BackupBAKpath=%Backuppath%\Current
  set BackupTXTpath=%Backuppath%\Current\txt
  </code></pre>
  
  <p>But the Problem is the variable CURRDB. The script handles it as a command because of the characters ! and = in the string. So I get an error that in cmd <code>'testtest' is not recognized as an internal or external command, operable programm or batch file.</code> So it seems like that the script removes the <code>!</code> and the <code>=</code> from the variable.</p>
  
  <p>So how can I escape the <code>!</code> and the <code>=</code> in the variable?</p>