|
|
#1 |
|
Junior Member
Join Date: Oct 2015
Posts: 1
|
Detecting default browser on Windows 8
Hi guys,
I have trouble detecting the default browser on Win 8.1 Pro, but it goes the same for Win 8 also. I have a script that worked just fine on Win 7: code: This doesn't work on Windows above Win 7. After this command: code: on Win 7 I can print $1 and get: "C:\Program Files\Internet Explorer\iexplore.exe" but for some reason, on Win 8.1, I get: "C:\Windows\system32\OpenWith.exe" and I always get BR = "00", meaning that some other browser (other than GC, FF, IE) is the default browser. Do you have any instructions, or code samples, that could help me overcome this Win 8 issue? Best, Stefan |
|
|
|
|
|
#2 | |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
There is no such thing as a default browser in Windows, a user can set FF to open .htm files, CH to open .html files, IE to open the HTTP protocol and Safari to open the HTTPS protocol if they wanted to. OpenWith.exe probably means the user has not chosen a default handler for .htm files yet. There are of course other browsers like Opera and Maxthon so you need to be able to handle BR = "00" anyway.
If you just want to open a .htm file or a URL you should just use ExecShell and not actually try to detect the browser. If you look at http://blogs.msdn.com/b/oldnewthing/.../10641381.aspx you see that what they call the default browser is the application that handles the http protocol. You can use the same detection if you want: Quote:
IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
|
#3 |
|
Major Dude
|
Try this simple code which is working for me (on all OSs):
PHP Code:
DebugMsg is simple MessageBox call. What you need is to set symbol IS_UNICODE correctly: If you are using Unicode NSIS. Cool looking installers with custom design: www.graphical-installer.com Create Setup Pages easily: www.install-designer.com Build installers in Visual Studio 2005-2022: www.visual-installer.com or RAD Studio 2009 - 11 Alexandria: www.rad-installer.com |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
This code is basically the same as the original, just a little broken! The OP is getting back a valid string so their system syntax is already correct!
Why invent a new Unicode define when we already have one? Why hardcode A and W suffix when it is not required? You should not use the t string type when forcing A/W. Did you actually test on everything from Win95 to Win10? Win95RTM did not ship with a browser... IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Nov 2012
Posts: 166
|
Anders
From your example, it turns out that something strange ... Windows 7 x32 Quote:
|
|
|
|
|
|
|
#6 | ||
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
Quote:
There can probably be multiple reasons why this is returned. It is unlikely that your machine does not have a open verb for http but I guess it could happen. A more likely reason is that a shell extension is the handler and not a simple .exe file, this is completely legal, there is no guarantee that you can find the name of the .exe that will run when you ShellExecute something... IntOp $PostCount $PostCount + 1 |
||
|
|
|
|
|
#7 | ||
|
Senior Member
Join Date: Nov 2012
Posts: 166
|
Got it ... ASSOCF_IS_PROTOCOL - in Win7 does not work ...
In Win7 x32 as possible : System::Call 'SHLWAPI::AssocQueryString(i ${ASSOCF_NOTRUNCATE}|${ASSOCF_REMAPRUNDLL}|${ASSOCF_NOFIXUPS}, i ${ASSOCSTR_EXECUTABLE}, t ".htm", t "open", t.r1, *i ${NSIS_MAX_STRLEN})i.r0' However, Win 10 x64 - it does not work ... and : System::Call 'SHLWAPI::AssocQueryString(i ${ASSOCF_NOTRUNCATE}|${ASSOCF_REMAPRUNDLL}|${ASSOCF_NOFIXUPS}|${ASSOCF_ISPROTOCOL}, i ${ASSOCSTR_EXECUTABLE}, t ".htm", t "open", t.r1, *i ${NSIS_MAX_STRLEN})i.r0' and : System::Call 'SHLWAPI::AssocQueryString(i ${ASSOCF_NOTRUNCATE}|${ASSOCF_REMAPRUNDLL}|${ASSOCF_NOFIXUPS}|${ASSOCF_ISPROTOCOL}, i ${ASSOCSTR_EXECUTABLE}, t "http", t "open", t.r1, *i ${NSIS_MAX_STRLEN})i.r0' Result: Quote:
!define ASSOCSTR_FRIENDLYAPPNAME 4 System::Call 'SHLWAPI::AssocQueryString(i ${ASSOCF_NOTRUNCATE}|${ASSOCF_REMAPRUNDLL}|${ASSOCF_NOFIXUPS}|${ASSOCF_ISPROTOCOL}, i ${ASSOCSTR_FRIENDLYAPPNAME}, t ".htm", t "open", t.r1, *i ${NSIS_MAX_STRLEN})i.r0' Result: Quote:
Last edited by stass; 10th October 2015 at 08:32. |
||
|
|
|
|
|
#8 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
ASSOCF_IS_PROTOCOL is documented as Win8+ but XP did not care when I tested but you should of course only set it for URL protocols like HTTP, not on file extensions like .htm.
If the function returns 0 then it was successful but like I already said, it does not mean you can always get the name of the .exe. If Microsoft uses a generic launcher then that is the design they chose and there might not be a lot you can do about it. IntOp $PostCount $PostCount + 1 |
|
|
|
|
|
#9 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
|
Another thing you can try is to read from the registry under \SOFTWARE\Clients\StartMenuInternet ( https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx "This registration is deprecated as of Windows 7"). You must see if there is a default in HKCU and fall back to HKLM (On my machine I have not used the default applications applet in the control panel so I don't have a Clients key under HKCU!)
IntOp $PostCount $PostCount + 1 |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|