Postinstall run from system32 directory

73 views
Skip to first unread message

Ed Czar

unread,
May 25, 2020, 11:59:39 PM5/25/20
to innosetup
My Innosetup script running in x64 mode successfully copies a 64-bit executable into the system32 directory.  The problem occurs when I try to do a "postinstall" run of that executable.

The script is initialized with the following so that it runs in x64 mode:

ArchitecturesAllowed = x64
ArchitecturesInstallIn64BitMode = x64
PrivilegesRequired=admin

In the [Run] section I try to launch the executable with the following lines and wind up with the following errors:

Filename: "{sys}\{#MyAppExeName}";Description: "Launch application"; WorkingDir: "{sys}"; Flags:  postinstall nowait skipifsilent
Error: CreateProcess failed; code 740.  The requested operation requires elevation

Filename: "{sys}\{#MyAppExeName}";Description: "Launch application"; WorkingDir: "{sys}"; Flags:  postinstall nowait skipifsilent runascurrentuser
Error: CreateProcess failed; code 740.  The requested operation requires elevation

Filename: "{sys}\{#MyAppExeName}";Description: "Launch application"; WorkingDir: "{sys}"; Flags:  nowait postinstall shellexec skipifsilent
Error: ShellExecuteEx failed; code 2.  The system cannot find the file specified

Filename: "{sys}\{#MyAppExeName}";Description: "Launch application"; WorkingDir: "{sys}"; Flags:  nowait postinstall shellexec skipifsilent runascurrentuser
Error: ShellExecuteEx failed; code 2.  The system cannot find the file specified


Changing the directory to the {app} directory:

Filename: {app}\{#MyAppExeName};Description: "Launch application3"; WorkingDir: "{app}"; Flags:  postinstall nowait skipifsilent runascurrentuser
Error: CreateProcess failed; code 740.  The requested operation requires elevation

Filename: {app}\{#MyAppExeName};Description: "Launch application"; WorkingDir: "{app}"; Flags:  nowait postinstall shellexec skipifsilent
This works!


For the 32-bit version of the software where the installation is done in 32-bit mode running postinstall with "shellexec" from the SysWOW64 directory it works.

Any thoughts?

Ed

Gavin Lambert

unread,
May 26, 2020, 2:03:41 AM5/26/20
to inno...@googlegroups.com
On 26/05/2020 15:59, Ed Czar wrote:
> My Innosetup script running in x64 mode successfully copies a 64-bit
> executable into the system32 directory.  The problem occurs when I try
> to do a "postinstall" run of that executable.
[...]
> For the 32-bit version of the software where the installation is done in
> 32-bit mode running postinstall with "shellexec" from the SysWOW64
> directory it works.

Your executable is marked with an administrator manifest (or is not
marked at all, and Windows is guessing that it requires admin
permissions), which is why it is failing to run without the "shellexec"
flag.

Solution: explicitly mark it with an invoker manifest instead (and
ensure that it doesn't actually need admin permissions).


As for why {sys} is not working but {app} is, when you do use
"shellexec": if you have a look at the "64-bit Installation Limitations"
section in the help file, you'll see that ShellExec is one of the things
that doesn't support disabling {sys} redirection. Thus it is not
possible to ShellExec anything in the 64-bit {sys} folder.

Solution: don't install it there, put it in {app} instead. It's usually
incorrect these days to install things to {sys} anyway -- that's for
Windows components, not yours.

Ed Czar

unread,
May 26, 2020, 10:39:31 AM5/26/20
to innosetup
Hi Gavin,

Thanks for the insight.

The executable is marked "asInvoker".  However, it also has uiAccess marked as "true" .  Perhaps this is why Innosetup is having a hard time launching the program.  (Please not that the PrivilegesRequired is set to "admin" so we know the setup is launched with Admin)

I am assuming is the setup program is run under Admin we should not have any issues launching the program.  Is that correct?

Are there any special considerations when the exe is marked with uiAccess = true?

Jernej Simončič

unread,
May 26, 2020, 12:37:47 PM5/26/20
to Ed Czar on [innosetup]
On Tuesday, May 26, 2020, 16:39:31, Ed Czar wrote:

> The executable is marked "asInvoker". However, it also has uiAccess marked
> as "true" . Perhaps this is why Innosetup is having a hard time launching
> the program.

This probably is the reason - uiAccess=true behaves similarly to
program being marked as requireAdministrator, so it requires
shellexec.

> I am assuming is the setup program is run under Admin we should not have
> any issues launching the program. Is that correct?

Unfortunately, in my experience starting an uiAccess=true program
already elevated doesn't always work properly (I've had the program
fail to start at all on some systems).

While I haven't tried this (my own uiAccess=true programs run from
Program Files), check if shellexec works with {sysnative} instead of
{sys}.

--
< Jernej Simončič ><><><><>< https://eternallybored.org/ >

If the shoe fits, it's ugly. If it's good, they discontinue it.
-- Law of Consumer Economics

Ed Czar

unread,
May 26, 2020, 12:48:24 PM5/26/20
to innosetup
Thanks for the suggestion but the {sysnative} returned a file not found.

Gavin Lambert

unread,
May 26, 2020, 7:35:58 PM5/26/20
to inno...@googlegroups.com
On 27/05/2020 02:39, Ed Czar wrote:
> I am assuming is the setup program is run under Admin we should not have
> any issues launching the program.  Is that correct?

postinstall implies runasoriginaluser, so the program is being run with
non-elevated permissions (hence the need to shellexec to re-elevate).

You can explicitly specify runascurrentuser to run it with the elevated
token, but bear in mind that this might be a different user account
(when UAC elevated with credentials rather than with consent); this may
cause issues if it needs to interact with other processes or load/save
settings or documents -- in particular when the user runs it again later
on then it will be in a different user context and may not be able to
find anything it did during the first run.

Simão Afonso

unread,
May 26, 2026, 11:52:28 AM (10 days ago) May 26
to innosetup
I'm pretty sure I'm hitting a similar problem. I need to run my app "under" conhost to force using the old "cmd.exe" instead of the new Windows Terminal, so I'm using:

Description: "{cm:LaunchProgram,{#MyAppName}}"; Filename: "{sys}\conhost.exe"; Parameters: "{app}\{#MyExeMain}"; Flags: postinstall nowait skipifsilent unchecked

I have the same Filename/Parameters combination in "Icons", and the Start Menu shortcuts work correctly. But under "Run", this always fails (see error message below).

I also tried running the main link with:

Description: "Run LINK"; Filename: "{group}\%APPNAME% Main Entrypoint.lnk"; Flags: postinstall nowait skipifsilent unchecked shellexec

but this also fails.

Here are the logs for these two attempts (minus internal names):

2026-05-26 16:09:39.699   -- Run entry --
2026-05-26 16:09:39.699   Run as: Original user
2026-05-26 16:09:39.699   Type: Exec
2026-05-26 16:09:39.699   Filename: C:\WINDOWS\system32\conhost.exe
2026-05-26 16:09:39.699   Parameters: %APP%\%APPEXE%.exe
2026-05-26 16:09:39.699   Exception message:
2026-05-26 16:09:39.699   Message box (OK):
                          Unable to execute file:
                          C:\WINDOWS\system32\conhost.exe
                         
                          CreateProcess failed; code 2.
                          The system cannot find the file specified.
2026-05-26 16:09:41.446   User chose OK.
2026-05-26 16:09:41.447   -- Run entry --
2026-05-26 16:09:41.447   Run as: Original user
2026-05-26 16:09:41.447   Type: ShellExec
2026-05-26 16:09:41.447   Filename: %GROUP%\%APPNAME% Main Entrypoint.lnk
2026-05-26 16:09:44.499   Exception message:
2026-05-26 16:09:44.499   Message box (OK):
                          Unable to execute file:
                          %GROUP%\%APPNAME% Main Entrypoint.lnk
                         
                          ShellExecuteEx failed; code 1223.
                          The operation was canceled by the user.
2026-05-26 16:09:46.482   User chose OK.


     Powertools Technologies Lda

R. Alves Redol 9 * 1000-029 Lisboa * Portugal
Phone: +351 214 009 555 * GPS: 38°44'10.927"N 9°8'26.757"W
E-mail: con...@powertools-tech.com * https://www.powertools-tech.com

Any personal data in this e-mail will be processed in compliance with the conditions of lawfulness pursuant to EU Reg. 2016/679. This email message, which includes any attachments, may contain confidential, proprietary and/or privileged information for the sole use of the intended recipient. Any unauthorized review, use, copying, disclosure or distribution is prohibited. If you are not the intended recipient, please immediately contact the sender by reply email and permanently destroy the original and any copies of this message.

O tratamento de dados pessoais eventualmente presentes nesta mensagem está salvaguardado nos termos previstos no Regulamento Europeu de Proteção de Dados UE 2016/679. Esta mensagem e quaisquer documentos em anexo são confidenciais. Se não for o destinatário desta mensagem, agradecemos que avise imediatamente o remetente e que a elimine sem a reproduzir, armazenar ou divulgar a qualquer entidades.

Martijn Laan

unread,
May 26, 2026, 12:20:41 PM (10 days ago) May 26
to innosetup
Hi,

Op 26-5-2026 om 17:20 schreef Simão Afonso:
Description: "{cm:LaunchProgram,{#MyAppName}}"; Filename: "{sys}\conhost.exe"; Parameters: "{app}\{#MyExeMain}"; Flags: postinstall nowait skipifsilent unchecked

By default, this runs conhost.exe from the 32-bit system directory. However, conhost.exe does not exist there, only in the 64-bit system directory, at least on my system.

Also see https://jrsoftware.org/ishelp/index.php?topic=32vs64bitinstalls

Greetings,
Martijn
Reply all
Reply to author
Forward
0 new messages