Archive: Using UAC Exec as vista admin


Using UAC Exec as vista admin
Hi,

I have spend the last few days trying to create an installer that does the following:

The installer is started with RequestExecutionLevel user and includes five sections. Four of those sections have functions that need to be executed as a user, those work fine.
The fifth section will start a executable, but it requires a vista admin account. The executable I try to start has the "RequestExecutionLevel admin" setting.

I have tried to use the UAC plugin, but it will ask for a admin password when starting the installer. Most users will not require the fifth option and therefore I would like the installer to ask for an admin password only when choosing or executing the fifth option in the section list.

Example 1:


install_no5:
UAC::RunElevated
UAC::Exec '' '"$INSTDIR\${APPFILE}"' '' ''


This causes the installer to ask for a admin password, but after logging in the installer starts all over again from the top and the executable does not start.

Example 2:


install_no5:
ExecWait '"$EXEDIR\Setup.exe"'


This causes the executable to run when the user is an admin, but when the user is not an admin he will not execute anything.


I hope someone can point me into the right direction with this issue.

1:
It is not possible to elevate a process on the fly, only new processes, thats why it works this way

2:
I'm not sure if I understand the problem here, but you might want to use userinfo::GetAccountType and disable the 5th section on your components page if the user is not a member of the admin group


Thanks a lot,

I now have included the solution given to you in point 2.

It's rather strange that a default user, running an installer in "RequestExecutionLevel user" mode, can not start a different installer with "RequestExecutionLevel admin". (You would think that you would just get the "administrator login screen", just as you would get when starting the installer through Windows Explorer)


A possible answer to that is that ExecWait uses createprocess and only ShellExecute will elevate when needed, createprocess just dies with an error.
If execshell works correctly but you need to wait, you could use UAC::ShellExecWait