Old 29th June 2007, 08:31   #1
Fluxie
Junior Member
 
Join Date: Dec 2006
Posts: 4
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:

code:

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:

code:

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.
Fluxie is offline   Reply With Quote
Old 29th June 2007, 08:58   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
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

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd July 2007, 12:16   #3
Fluxie
Junior Member
 
Join Date: Dec 2006
Posts: 4
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)
Fluxie is offline   Reply With Quote
Old 2nd July 2007, 13:58   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
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

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump