Code: Select all
getBrowser()
{
; Function by Michael Weiner, Indianapolis, Indiana, U.S.A. on 18 May 2020
; This function gets the full path to the Web browser.
keyNum := 0
browser =
class =
cline =
extkey1 = HKEY_CLASSES_ROOT
extkey2 = HKEY_CURRENT_USER\Software\Classes
extkey3 = HKEY_LOCAL_MACHINE\Software\Classes
While (NOT class) AND (keyNum < 3) ; Try three different keys; use the first key with value data
{
keyNum += 1
key := extkey%keyNum% ; Get the key name
RegRead, class, %key%, .html ; Read the key's value data for value name = .html
}
If class ; A browser class name was identified
{
RegRead, cline, %key%\%class%\shell\open\command ; Get the browser's command line
If cline
{
word := StrSplit(cline,"""") ; Split into array by quotation mark
browser := word[1]
If NOT browser ; Command line starts with a quotation mark
browser := word[2]
browser := RegExReplace(browser,"\s+$") ; Delete trailing white space
}
}
Return browser
}