Old 29th January 2007, 19:36   #1
llebron
Junior Member
 
Join Date: Jan 2006
Posts: 2
Detect browser script

I am learning to use NSIS. Based on some wiki information I put together the following script. However, the StrCmp lines are not working. I'm sure it's something wrong with my syntax. Any help would be appreciated.

Outfile "detectbrowser.exe"
ShowInstDetails show

Section "Detect default browser"

ReadRegStr $R3 HKCR ".htm" ""
ReadRegStr $R4 HKCR "$R3\shell" ""
ReadRegStr $R3 HKCR "$R3\shell\$R4\command" ""
Pop $R3 ;Get the return value

DetailPrint "Default Browser"
DetailPrint "$R3"

StrCmp $R3 iexplore.exe 0 +2
DetailPrint "Default Browser: IE"

StrCmp $R3 firefox.exe 0 skip
DetailPrint "Default Browser: Firefox"
skip:

SectionEnd

thanks,

Luis
llebron is offline   Reply With Quote
Old 29th January 2007, 21:13   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
When you Pop you get from the stack the return value that a plugin or function has pushed (Push) to the stack

The way you use to read the registry is also wrong, at least regarding to my registry, should be:
code:
ReadRegStr $R0 HKCR ".htm" ""
ReadRegStr $R0 HKCR "$R0\shell\open\command" ""

DetailPrint "Default Browser"
DetailPrint "$R0"

Still you need to process the string if you want export browser's name.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 29th January 2007, 21:20   #3
llebron
Junior Member
 
Join Date: Jan 2006
Posts: 2
Quote:
code:
ReadRegStr $R0 HKCR ".htm" ""
ReadRegStr $R0 HKCR "$R0\shell\open\command" ""

DetailPrint "Default Browser"
DetailPrint "$R0"

Still you need to process the string if you want export browser's name.
I get similar result with this
code:

ReadRegStr $R0 HKCR ".htm" ""
ReadRegStr $R4 HKCR "$R0\shell" ""
ReadRegStr $R0 HKCR "$R0\shell\$R4\command" ""
DetailPrint "Default Browser"
DetailPrint "$R0"



However, how can I tell if "iexplore.exe" is contained in the $RO variable?

thanks,

Luis
llebron is offline   Reply With Quote
Old 29th January 2007, 21:57   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
I get similar result with this

code:
ReadRegStr $R0 HKCR ".htm" ""
ReadRegStr $R4 HKCR "$R0\shell" ""
ReadRegStr $R0 HKCR "$R0\shell\$R4\command" ""
DetailPrint "Default Browser"
DetailPrint "$R0"
I suppose if browser is firefox you'll get an empty string because according to my registry (ReadRegStr $R4 HKCR "$R0\shell" "") is empty.
Quote:
However, how can I tell if "iexplore.exe" is contained in the $RO variable?
If you're looking for specific browser in order to proceed with specific actions [case a: case b: case c: etc] you need to export browser's name from string, There are decades of string manipulation functions at http://nsis.sf.net most likely you'll find one ready to do the job for you.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump