title: Batch file ends unexpectedly. Has been working for years but has suddenly stopped working
body: <p>I have a batch file which hids a folder. It has been working for years but has suddenly stopped working and I can't work out why.</p>
  <pre><code>@ECHO OFF
  if EXIST &quot;Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}&quot; goto UNLOCK
  if NOT EXIST Private goto MDPrivate
  :CONFIRM
  echo Are you sure you want to lock this folder? (Y/N)
  set/p &quot;cho=&gt;&quot;
  if %cho%==Y goto LOCK
  if %cho%==y goto LOCK
  if %cho%==n goto END
  if %cho%==N goto END
  echo Invalid choice.
  goto CONFIRM
  :LOCK
  ren Private &quot;Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}&quot;
  attrib +h +s &quot;Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}&quot;
  echo Folder locked
  goto End
  :UNLOCK
  echo Enter password to Unlock Your Secure Folder
  set/p &quot;pass=&gt;&quot;
  if NOT %pass%== takingcareofbusiness goto FAIL
  attrib -h -s &quot;Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}&quot;
  ren &quot;Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}&quot; Private
  echo Folder Unlocked successfully
  goto End
  :FAIL
  echo Invalid password
  goto end
  :MDPrivate
  md Private
  echo Private created successfully
  goto End
  :End
  </code></pre>
  <p>The problem initially presents as a problem with the attrib settings not being applied in the LOCK section but on further investigation (putting an echo after the ren command), the batch file closes after the ren command.</p>
  <p>What's even more weird is that is runs perfectly well in Command Prompt but not when running it from Windows Explorer.</p>
  <p>User has Administrator priviledge but it just stops working.</p>