Launch default browser for links in SmartSearch results

Last modified by Admin on 2024/08/08 21:19

Introduction

Due to the fact that SwyxIt! is using Internet Explorer Controls in its WebExtensions using any http: or https: links will always open an Internet Explorer instead of the system's default browser.

Workaround

As a workaround we need a local custom URL handler. This custom URL handler can then be used in WebExtensions instead of the http: links.

Install the custom URL handler

The custom URL handler can be installed by importing these registry keys. The text in the green box can be saved into a .reg-file or distributed to all clients by using a domain policy. This registers an url-handler in form of default: instead of http:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\default]
"URL Protocol"=""
@="URL:default"

[HKEY_CLASSES_ROOT\default\Shell]

[HKEY_CLASSES_ROOT\default\Shell\Open]

[HKEY_CLASSES_ROOT\default\Shell\Open\Command]
@="c:\\Windows\\SysWoW64\\cscript.exe C:\\ProgramData\\3iMedia\\Scripts\\urlhandler.vbs \"%0\""

Install the local script

To actually open the default browser locally, the following script has to be saved in "C:\ProgramData\3iMedia\Scripts\UrlHandler.vbs"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Dim Temp, ToRun, fso, ProgramPath, PathToCheck
Set fso = CreateObject("Scripting.FileSystemObject")
Set WscriptShell = CreateObject("WScript.Shell")

Temp = WScript.Arguments(0)
ToRun = ""
ProgramPath = ""

' No argument, no action
If IsNull(Temp) Then WScript.Quit

If Left(Temp, 8) = "default:" Then

 
PathToCheck = WscriptShell.ExpandEnvironmentStrings("%ProgramW6432%") & "\Google\Chrome\Application\chrome.exe"
 
If fso.FileExists(PathToCheck) = True Then ProgramPath = Chr(34) & PathToCheck & Chr(34)

 
PathToCheck = WscriptShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") & "\Google\Chrome\Application\chrome.exe"
 
If fso.FileExists(PathToCheck) = True Then ProgramPath = Chr(34) & PathToCheck & Chr(34)

End If

If ProgramPath = "" Then

 
' Fallback to IE
 
PathToCheck = WscriptShell.ExpandEnvironmentStrings("%ProgramW6432%") & "\Internet Explorer\iexplore.exe"
 
If fso.FileExists(PathToCheck) = True Then ProgramPath = Chr(34) & PathToCheck & Chr(34)

 
PathToCheck = WscriptShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") & "\Internet Explorer\iexplore.exe"
 
If fso.FileExists(PathToCheck) = True Then ProgramPath = Chr(34) & PathToCheck & Chr(34)
End If

ToRun = Replace(Temp, "default:", ProgramPath & " ")
WscriptShell.Run ToRun,1,False

The script might have to be customized due to different paths on the local client. Using another browser than Google Chrome also requires a change to the application path. If the browser cannot be found the script falls back to Internet Explorer.

Using the custom URL handler

In order to get the custom URL handler to work, all http: and https: links have to be replaced with default: in the ESTOS replicator.