Skip to content

Instantly share code, notes, and snippets.

@AveYo
Last active October 2, 2021 08:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AveYo/e325b4876ab0bec4481697640f706cc7 to your computer and use it in GitHub Desktop.
Save AveYo/e325b4876ab0bec4481697640f706cc7 to your computer and use it in GitHub Desktop.
Web Search Choice for Cortana - direct input to console fixed!

Web Search Choice for Cortana - current user (no need for admin rights to run)

Replace default taskbar web search on bing via Edge with your preference

Apply from Command Prompt without WebSearchChoice.bat:

Adjust iexplore.exe google.com/search?q= at the end of the long first line

reg add "HKCU\Software\Classes\WebSearchChoice\shell\open\command" /ve /d "mshta.exe \"javascript:window.close(q='%1'.split('%%3Fq%%3D')[1].split('%%26')[0],new ActiveXObject('WScript.Shell').Run('iexplore.exe google.com/search?q='+q))\"" /f 2>nul >nul
reg add "HKCU\Software\Classes\WebSearchChoice" /v "URL Protocol" /d "microsoft-edge" /f 2>nul >nul
reg add "HKCU\Software\Classes\WebSearchChoice" /ve /d "WebSearchChoice" /f 2>nul >nul
reg add "HKCU\Software\Clients\WebSearchChoice\Capabilities\UrlAssociations" /v "microsoft-edge" /d "WebSearchChoice" /f 2>nul >nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\microsoft-edge\OpenWithProgids" /v "URL:microsoft-edge" /t REG_NONE /f 2>nul >nul
reg add "HKCU\Software\RegisteredApplications" /v "WebSearchChoice" /d "Software\\Clients\\WebSearchChoice\\Capabilities" /f 2>nul >nul
echo.
echo  OPEN Choose default apps by protocol
echo  PICK Microsoft-Edge (URL:microsoft-edge)
echo  PICK Microsoft (R) HTML Application host
start ms-settings:defaultapps
timeout /t -1
;

Remove from Command Prompt (if Apply fails, do this first):

reg delete "HKCU\Software\Classes\WebSearchChoice" /f 2>nul >nul
reg delete "HKCU\Software\Clients\WebSearchChoice" /f 2>nul >nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "WebSearchChoice_microsoft-edge" /f 2>nul >nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\microsoft-edge\OpenWithProgids" /v "URL:microsoft-edge" /f 2>nul >nul
reg delete "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\microsoft-edge\UserChoice" /f 2>nul >nul
reg delete "HKCU\Software\RegisteredApplications" /v "WebSearchChoice" /f 2>nul >nul
;
@echo off &title WebSearchChoice
set "browser=iexplore.exe"
set "url=google.com/search?q="
echo.
echo Will override Cortana search Edge browser with: %browser%
set/p "browser_choice=-Enter new choice, or press Enter to use above: "
if "%browser_choice%"=="0" goto uninstall
echo.
echo Will override Cortana search bing url with: %url%
set/p "url_choice=-Enter new choice, or press Enter to use above: "
if "%url_choice%"=="0" goto uninstall
echo.
echo To remove, run script again and enter: 0
if not defined browser_choice set "browser_choice=%browser%"
if not defined url_choice set "url_choice=%url%"
echo [ %browser_choice% %url_choice% ]
call :uninstall >nul 2>nul
reg add "HKCU\Software\Classes\WebSearchChoice" /v "URL Protocol" /d "microsoft-edge" /f 2>nul >nul
reg add "HKCU\Software\Classes\WebSearchChoice" /ve /d "WebSearchChoice" /f 2>nul >nul
reg add "HKCU\Software\Classes\WebSearchChoice\shell\open\command" /ve /d "mshta.exe \"javascript:window.close(q='%%1'.split('%%%%3Fq%%%%3D')[1].split('%%%%26')[0],new ActiveXObject('WScript.Shell').Run('%browser_choice% %url_choice%'+q))\"" /f 2>nul >nul
reg add "HKCU\Software\Clients\WebSearchChoice\Capabilities\UrlAssociations" /v "microsoft-edge" /d "WebSearchChoice" /f 2>nul >nul
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\microsoft-edge\OpenWithProgids" /v "URL:microsoft-edge" /t REG_NONE /f 2>nul >nul
reg add "HKCU\Software\RegisteredApplications" /v "WebSearchChoice" /d "Software\\Clients\\WebSearchChoice\\Capabilities" /f 2>nul >nul
echo.
echo OPEN Choose default apps by protocol
echo PICK Microsoft-Edge (URL:microsoft-edge)
echo PICK Microsoft (R) HTML Application host
start ms-settings:defaultapps
timeout /t -1
exit/b
:uninstall
reg delete "HKCU\Software\Classes\WebSearchChoice" /f 2>nul >nul
reg delete "HKCU\Software\Clients\WebSearchChoice" /f 2>nul >nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" /v "WebSearchChoice_microsoft-edge" /f 2>nul >nul
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\microsoft-edge\OpenWithProgids" /v "URL:microsoft-edge" /f 2>nul >nul
reg delete "HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\microsoft-edge\UserChoice" /f 2>nul >nul
reg delete "HKCU\Software\RegisteredApplications" /v "WebSearchChoice" /f 2>nul >nul
exit/b
* text=auto
* eol=crlf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment