title: Windows Batch file to get value of wildcard matched line, check for substring and append string if required
body: <p>I'm totally new to command scripting and could use a little direction...</p>
  
  <p>I need to check if a certain line in a .ini file exists, however I only know what part of the line will be. If it exists, I know it will start with the string "Extmgr_Addins=" and it could have any number of comma seperated string values attributed to it.</p>
  
  <p>If I find this line, I need to see if contains the substring "mc". If it does have "mc" already, then do nothing. If it doesn't, I need to append the string ",mc" to the end of that line. This is what i have so far:</p>
  
  <pre><code>for /f "TOKENS=*" %%x in (myFile.ini) do (
  
  set line=%%x
  set line=!tst:Extmgr_Addins!
  
  if not !line!==%%x ( 
       REM matched string ExtMgr_Addins
     set hasMC = %%x
     set hasMC=!hasMC:mc!
  
     if not !line!==%%x (
  
          REM matched substring of mc - do nothing
  
          )else(
  
                           REM here is where I would append "mc" to this line                 
          )
              )
  </code></pre>