title: Switch between two .reg files
body: <p>I'm looking for a quick and easy way (I don't need any error checking) to switch between two reg files by opening a batch file.</p>
  
  <p>If a user runs a batch file, the batch file should merge reg file A to the registry. If the user runs it again, the batch file should merge reg file B to the registry. If the user runs it again, file A is merged... you get the point.</p>
  
  <p>In general, I think there are two ways to do this:</p>
  
  <ol>
  <li>Create some sort of variable to store which reg should be run next.</li>
  <li>Check the registry key values to see which reg has been merged most recently (probably the preferred method).</li>
  </ol>
  
  <p>Currently, I'm doing this:</p>
  
  <pre><code>REG QUERY "KeyName" /v "ValueName" | Find "x"
  
  IF ERRORLEVEL 1 regedit /S file1.reg
  IF ERRORLEVEL 0 regedit /S file2.reg
  </code></pre>
  
  <p>The REG QUERY part seems to work, but at the <code>IF ERRORLEVEL</code> statements something is going wrong. But maybe I should use a different method altogether.</p>
  
  <p>Hoping for some suggestions.. Thanks in advance!</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Sorry for being a bit vague: I believe the previous solution didn't work, because when the first <code>IF</code> is correct, the second <code>IF</code> will be too after the first <code>IF</code>'s command. So I will need an <code>IF ELSE</code> statement to prevent running the second <code>IF</code>.</p>
  
  <p>I've now come up with this solution, which works:</p>
  
  <pre><code>REG QUERY "KeyName" /v "ValueName" | Find "x
  IF ERRORLEVEL 1 (REGEDIT /S "file1.reg") ELSE REGEDIT /S "file2.reg"
  </code></pre>
  
  <p>I was also wondering: would it be an improvement to have the registry key/values added inside the batch file instead of using seperate .reg files? The value types are REG_BINARY and REG_DWORD.</p>