title: Is it possible to convert this multi-line batch script into a working one liner?
body: <p>I would like to make my multi-line batch script into a one liner so I can use it as a file explorer context menu entry. I know that I can link the batch file in the registry to call the batch script and it does work.</p>
  
  <p>I am trying to get more proficient with my coding so I was wondering if anyone could take a look and give me some pointers. I have been researching and testing to find the answer myself but have come up short. I will include two scripts that both achieve the same thing and both work if I link the batch script path in the registry command key.</p>
  
  <p><code>Script A</code> is more complex and offers more options for the code to follow depending on what it encounters during it's run. <code>Script B</code> is simpler and still achieves the main purpose of the script in the end.</p>
  
  <p>Script A is called from the registry in a custom context menu that runs this line of code in the registry entry's command key.</p>
  
  <p><code>"C:\Users\jholl\OneDrive\Documents\01_Scripts\01_REGISTRY_MAIN\Registry_Edits\File_Explorer\Context_Menu\Restart_Explorer\Restart_Explorer.bat" "%V"</code></p>
  
  <p>The reason I added the <code>"%V"</code> at the end of the bat file is to pass custom command line arguments to the batch script so that when I access the context menu using a folder's directory\background and click the menu entry named "Restart Explorer" it captures the current directory in the "%~1" argument that I can then use to reopen file explorer to that same folder when I relaunch explorer.exe at the end of the script after taskkill closes all instances of explorer.exe.</p>
  
  <p>This is <strong>way more convenient</strong> than having to relocate the folder again manually by navigating through file explorer.</p>
  
  <pre><code>@echo off
  setlocal
  prompt $g
  
  call :restart_explorer "%~1"
  goto:eof
  
  :restart_explorer
  tasklist /fi "imagename eq explorer.exe" | find /i /n "explorer.exe" &gt;nul
  if "%errorlevel%"=="0" (
  start "" /wait taskkill /f /im explorer.exe &amp;&amp;^
  start "" explorer &amp;&amp;^
  start "" /max explorer "%~1" &amp;&amp;^
  exit /b
  ) else (
  goto failed
  )
  
  :failed
  cls &amp;&amp; echo.
  echo taskkill was unable to find/close explorer.exe
  echo it is most likely not running
  timeout 5 &gt;nul
  exit /b
  
  </code></pre>
  
  <p>Script B is just a simplified code. No more. Same goal as above with less steps.</p>
  
  <pre><code>@echo off
  setlocal
  prompt $g
  
  call :restart_explorer "%~1"
  goto:eof
  
  :restart_explorer
  tasklist /fi "imagename eq explorer.exe" | find /i /n "explorer.exe" &gt;nul
  if "%errorlevel%"=="0" (start "" /wait taskkill /f /im explorer.exe)
  start "" explorer &amp;&amp;^
  start "" /max explorer "%~1" &amp;&amp;^
  exit /b
  </code></pre>
  
  <p>Any ideas to help give me a boost would be greatly apprecaited. Again I'm looking to turn this into a one liner.</p>