Archive: Detect browser script


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


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:

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.

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

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

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.
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.