title: Prevent overwriting a file using cmd if exist
body: <p>I am currently writing a .bat batch file that executes an installation file. Before it runs the installation file I check to see if the directory exists to avoid re-installing the application.</p>
  
  <p>I do this by using a <code>If Not Exist filename</code> statement. If the installed file doesn't exist, I then execute the installation file.</p>
  
  <p>For some reason, when I test it with the application where it has been installed already, it is still trying to reinstall the application over it.</p>
  
  <p>Here is a snippet of my code: </p>
  
  <pre><code>cd "C:\Documents and Settings\John\Start Menu\Programs\"
  pause
  If NOT exist "Software Folder"\ (
   start \\filer\repo\lab\"software"\"myapp"\setup.exe
   pause
  ) 
  </code></pre>
  
  <p>Where <code>SoftwareFolder</code> is a subdirectory of <code>"C:\Documents and Settings\John\Start Menu\Programs\".</code> I am checking to see if it exists in my <code>Programs</code> folder.</p>
  
  <p>I know nothing is wrong with my <code>start</code> command. I have a feeling something is wrong with my beginning <code>CD</code> command or one of its parameters.</p>
  
  <p>Thanks a lot, guys!</p>