title: Batch File To Loop Menu
body: <p>I'm creating a batch file that will launch when I login to my user account. I followed <a href="http://www.sevenforums.com/tutorials/78083-batch-files-create-menu-execute-commands.html" rel="nofollow">this tutorial</a> to create a batch file with a menu. It works, however, if the user enters a number that is not listed, I want it to go back to the menu. How would I implement that?</p>
  
  <p><strong>Side note:</strong> I understand I could use something more flexible like Powershell, however, I prefer batch files.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>@ECHO OFF
  CLS
  :MENU
  echo Welcome %USERNAME%
  
  echo 1 - Start KeePass
  echo 2 - Backup
  echo 3 - Exit
  
  SET /P M=Type 1,2,3 then press Enter:
  
  
  IF %M%==1 GOTO StarKeePass
  IF %M%==2 GOTO Backup
  IF %M%==3 GOTO :EOF
  
  
  :StarKeePass
  SET keePass="%USERPROFILE%\KeePass\KeePass-2.30\KeePass.exe"
  SET kdb="%USERPROFILE%\KeePass\PasswordDatabase\PasswordDatabase.kdbx"
  
  echo I'll start KeePass for You
  START "" %keePass% %kdb% 
  
  GOTO MENU
  
  :Backup
  SET backup="%USERPROFILE%\backup.bat"
  call %backup%
  
  GOTO MENU
  </code></pre>