2

I have an NSIS script that has a show readme function that launches a pdf successfully in all OS's using the following line:

ExecShell "open" "$0\$(APP_DATA_PATH)\AppData\Readme\readme_$(LOCAL_CODE).pdf"

BUT - not in Windows 8. If any other reader other than Adobe is the default reader, it seems to be ok. We have to support Adobe and there seems to be nothing wrong with launching the pdf file elsewhere in Windows 8.

Is there any other NSIS command I can try to launch the file that I can try? Any other suggestions?

1 Answer 1

0

Try using the default verb: ExecShell "" "c:\full\path\to\file.pdf"

Edit:

Section

StrCpy $0 "$desktop\test.pdf"

; This should be the same as using ExecShell
System::Call 'shell32::ShellExecute(i$hwndparent,i0,t"$0",i0,i0,i5)i.r1'
DetailPrint "ShellExecute: Return=$1 (> 32 for success)"

; Let's try really hard by using SEE_MASK_INVOKEIDLIST
!define SEE_MASK_INVOKEIDLIST 0x0000000C
!define SEE_MASK_FLAG_DDEWAIT 0x00000100
System::Call '*(i60,i${SEE_MASK_INVOKEIDLIST}|${SEE_MASK_FLAG_DDEWAIT},i$hwndparent,i0,t"$0",i0,i0,i5,i,i0,i,i,i,i,i)i.r2' ; Allocate SHELLEXECUTEINFO
System::Call 'shell32::ShellExecuteEx(ir2)i.r1'
System::Free $2
DetailPrint "ShellExecuteEx: Success=$1"

SectionEnd
5
  • Tried this and same issue. I also tried: ExecShell open "<path>" (where open is not in quotes). Same thing. Is there an equivalent nsis cmd to launch a file? I am building with nsis version 2.46. Any suggestions? Appreciate the help people :)
    – Forrie
    Dec 10, 2013 at 8:22
  • ExecShell is just a thin wrapper around ShellExecute. I'll write some code that calls ShellExecute directly for you later tonight...
    – Anders
    Dec 10, 2013 at 12:22
  • Cheers actually I found that if I disable the "Enable Protected Mode at startup" in Acrobat Reader it works fine. It only doesn't work with this enabled? It works ok either way if I double click the PDF = maybe it's permission thing?
    – Forrie
    Dec 10, 2013 at 16:37
  • Hey I found a workaround using the following code: Exec '"$WINDIR\explorer.exe" "$0\$(APP_DATA_PATH)\AppData\Readme\readme_$(LOCAL_CODE).pdf"' Turns out Adobe Acrobat 11 has a preference for "Enable Protected Mode". If this is on then you will not be able to open PDF from nullsoft using ExecShell. So I used the above line as a workaround i.e. piggy backing off the explorer.exe process. Thanks for your help :)
    – Forrie
    Dec 11, 2013 at 8:54
  • Did ShellExecuteEx work? That explorer.exe hack is ugly and you are lucky that it does not popup with a error message...
    – Anders
    Dec 11, 2013 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.