title: Find exact substring from line using batch script
body: <p>Now I'm trying to write a script which will  get exact string from the line. For example:</p>
  
  <pre><code>echo asdf C:\ | findstr /C:"C:\\" 1&gt;nul 
  if errorlevel 1 ( echo not found ) else ( echo found )
  </code></pre>
  
  <p>In above script, i just wanna make sure that C:\ drive exist in echo command. But when i add some text to echo command like this:</p>
  
  <pre><code>echo asdf C:\sdfdf | findstr /C:"C:\\" 1&gt;nul
  if errorlevel 1 ( echo not found ) else ( echo found )
  </code></pre>
  
  <p>It still tell me C:\ exist. I just want to find exact string in line. Can someone suggest me something?</p>
  
  <p>Thanks in advanced!</p>
  
  <p>Sorry for my bad code and English!</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>Sorry guys,</p>
  
  <p>Let me explain more about my idea. I was working on Windows Server migration. From old server I have to migrate shared folder which doesn't contains Default Share or Remote Admin location to new server. I tried code a batch script like below to list all shared folder which i need to migrate and next time i will modify it to automatically using xcopy to copy it to the new server. But I'm stucking with getting exact string from output to list exact shared folder which i need. Here is my script:</p>
  
  <pre><code>@echo off
  setlocal enabledelayedexpansion
  REM Get list shared folder
  echo:
  echo ^&lt;=================Get list shared folder================^&gt;
  for /F "tokens=* skip=1" %%i in ('"wmic share get name,path"') do (
      for /F "tokens=1" %%s in ('echo %%i') do (
      REM Check content doesn't contains $ special character, ECHO text
          echo %%s | findstr /C:"$" 1&gt;nul
          REM if not contains $
          if errorlevel 1 (
          REM if not contains ECHO text
              echo %%s | findstr /C:"ECHO" 1&gt;nul
              if errorlevel 1 (
                  echo %%i
                  echo %%i | findstr /C:"C:\\" 1&gt;nul
                  if errorlevel 1 (
                      echo %%i
                  )
              )
          )
      )
  )
  pause
  </code></pre>
  
  <p>Thank you guys all very much. Can everybody suggest me how to find exact drive like D:\, C:..etc. to exclude it from the result?</p>
  
  <p>Thanks in advanced!</p>
  
  <p>P/s: Sorry for my bad code and poor English.</p>