Hello,
after a lot of testing again I found out that having "requireAdministrator" in
the "upd.exe" would cause problems, ie. it won't start at all.
My update system is as follows:
(1) when my program, "myprog.exe", is about to exit it downloads "upd.exe" from
internet. All are 32-bit win32 exes.
"myprog.exe" does have a manifest with "requireAdministrator"
"upd.exe" does have a manifest with "asInvoker" (NOT "requireAdministrator")
(2) Just prior to exiting "myprog.exe" runs using plain CreateProcess() (not
ShellExecute) function ro run the "upd.exe" and then exits.
NOTE! if "upd.exe" has "requireAdministrator" in its manifest Createprocess()
won't run it at all and I get the 740 error. However "asInvoker" in the manifest
works fine.
(3) "upd.exe" is now running. Its has a resource file embedded "udpdater.exe".
"upd.exe" writes the "udpdater.exe" on disk and starts to exit.
(4) "upd.exe" is about to exit but before exiting it runs a
ShellExecute(NULL, "runas","updater.exe","2", NULL, SW_SHOWNORMAL);
"updater.exe" does have a manifest with "requireAdministrator"
(5) An UAC windows pops up asking if I want to run "updater.exe". I click OK and
"updater.exe" is now running. Its has a resource file embedded "myprog.exe".
which it writes the on disk replcaing the old "myprog.exe".
None of the rigmarola & UAC popping up would have been prevented if:
a) The very first "myprog.exe" had used ShellExecute and not CreateProcess.
or
b) The very first "myprog.exe" would have had full Administrator rights
(allthough the manifest does have it) or Windows 8 compatibility mode on.