How to close Microsoft Edge browser's current tab from command prompt?

Samiul picture Samiul · Oct 18, 2017 · Viewed 10.1k times · Source
>start microsoft-edge:http://google.com

Its opened google.com in edge browser new tab. Now I want to close. Here I am using stop but its not working.

>stop microsoft-edge:http://google.com

Answer

Bryan__T picture Bryan__T · Jul 5, 2019

taskkill /F /IM MicrosoftEdge.exe will kill it dead, but this will also terminate any other instances as well. In my experience, this force close will re-open with all tabs that were open before being "killed" even with Edge configured to not open with previous pages. My workaround to that was to taskkill /F /IM MicrosoftEdgeCP.exe repeatedly, with a 1 second delay, until all tabs were closed (going too fast did not kill all tabs). This also killed Edge when the last tab was closed.

Example

start https://www.bing.com/search?q=a
timeout 3
start https://www.bing.com/search?q=ab
timeout 3
start https://www.bing.com/search?q=abc
timeout 3

:KillEdge
timeout 1
taskkill /F /IM MicrosoftEdgeCP.exe
if %errorlevel% NEQ 0 (goto :eof) else (goto KillEdge)