title: I want to make .bat file which deletes temps (starts minimized and closes automatically)
body: <p>I have come up with the following code which starts minimized, waits 5 seconds (for slow PC) deletes temp files after and should automatically close, but for some reason, automatic close is not working, .bat file stays minimized.</p>
  
  <p>I tried using exit command but it has 0 effect because goto :EOF prevent it from execution, but if I will remove goto :EOF script won't delete temp files</p>
  
  <pre><code>if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 &amp;&amp; start "" /min "%~dpnx0" %* &amp;&amp; exit
  PING localhost -n 5 &gt;NUL
  @echo off
  setlocal
  call :Clear_Folder %SystemRoot%\TEMP
  pushd C:\Users
  for /d %%k in (*) do if exist "%%k\AppData\Local\Temp" call :Clear_Folder "%%k\AppData\Local\Temp"
  popd
  endlocal
  goto :EOF
  :Clear_Folder
  pushd "%~1"
  for /d %%i in (*) do rd /s /q "%%i"
  del /f /q *
  popd
  goto :EOF
  exit
  </code></pre>
  
  <p>I'm looking forward to fix last step auto close, all other features work fine, the script starts minimized, it deletes temp files but after all of this it won't close itself and it stays minimized.</p>