Skip to content
⌘ NSIS Forum Archive

UAC_AsUser_ExecShell doing nothing

10 posts

laughingman86#

UAC_AsUser_ExecShell doing nothing

hi

at the end of install need to start a program, so using this string
!insertmacro UAC_AsUser_ExecShell "" "$INSTDIR\${APP_EXE_FILE}" "" "" ""
But it isn't running

On init using this:
Function .OnInit
!insertmacro UAC_RunElevated
# call userInfo plugin to get user info. The plugin puts the result in the stack
userInfo::getAccountType
# pop the result from the stack into $0
pop $0
# compare the result with the string "Admin" to see if the user is admin.
# If match, jump 3 lines down.
strCmp $0 "Admin" +2
# if there is not a match, quit
Abort
# otherwise, continue

What am i doing wrong?
Anders#
There was a fix related to $instdir in the plugin recently so make sure you have the latest version. Also, you .onInit code is all wrong.
laughingman86#
Thanks, also appearently my installer file uses ANSI encoding so most of the commands didn't work right.
i used this onInit code to test my admin rights - because of the above reason.
So now i test this onInit

!insertmacro UAC_RunElevated
${IfNot} ${UAC_IsAdmin}
Quit
${EndIf}

and it works fine
browserseal#
I'm having exactly the same problem, !insertmacro UAC_AsUser_ExecShell '' '"$TEMP"' '' '' '' has no effect and it is not clear how to debug this.

Could not figure out how the original poster solved his problem...
Anders#
I don't think starting $temp would work no matter what:

Admin's $temp is c:\users\admin\... , the normal user cannot access that path...
MSG#
Also I'm pretty sure you can't just 'execute' a directory... You'll probably want to run a function as user, and in that function do Exec $windir\explorer.exe /n,"$temp" or something like that.
browserseal#
Yeah... you are probably right about the user not being able to access the admin's temp directory. I wonder how can I make NSIS download something to a directory that will be later accessible by the user...

P.S. Of course I'm not trying to run the directory, I removed the program name after I copy-pasted the code.