1
votes

How do you open PDFs from an Inno Setup installer on Windows 10? I'm trying to display help documents, and the technique that I use (based on comments on this question) and that works for Windows 7 results in nothing happening when running on Windows 10 (file doesn't open, and no error message is reported).

Specifically, when trying to open a PDF (either before installation in a custom code section using ShellExec() or after installation in the [Run] section using the shellexec flag) in a installer that requires elevated privileges, it will spawn 2 Adobe processes, but no windows will open (and furthermore, no other PDFs can be opened until those processes are manually killed). However, the PDF will open if:

  1. Another PDF is already open,
  2. The installer was launched from an already-elevated command prompt, or
  3. The installer was lanuched from Inno Setup Studio

In all other situations, the PDF will not launch (and until you kill the 2 Adobe processes, no other PDF will open).

This is essentially the code that works on Windows 7 but not Windows 10:

ExtractTemporaryFile('test.pdf');
ShellExec('open',
  AddQuotes(ExpandConstant('{tmp}\test.pdf')), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
1
Chances are that there is no shell command registered for the verb open when running as an admin. Did you try just passing '' instead of open? (This would also explain why ShellExecAsOriginalUser works when ShellExec does not - the non-admin has the open verb action assigned for PDF files.) The default for newer Acrobat Reader versions is Read, not Open, and using an empty string will cause it to use the default action.Ken White
No luck, passing '' to ShellExec has the same result. However, that's good to know that read is the new default action, thanks.dbc

1 Answers

1
votes

I suspect that something is going on with privileges, since the result is different depending on how the installer is launched (e.g. from an already elevated process vs. elevating after starting).

Using ShellExecAsOriginalUser works. e.g.:

ExtractTemporaryFile('test.pdf');
ShellExecAsOriginalUser('open',
  AddQuotes(ExpandConstant('{tmp}\test.pdf')), '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);

I don't know if it is a bug or intended functionality that ShellExec doesn't work for this purpose on Windows 10 and ShellExecAsOriginalUser does.