Skip to content
⌘ NSIS Forum Archive

Launching installed exe with UAC.nsh works but arguments passing not

5 posts

AndyJoeB#

Launching installed exe with UAC.nsh works but arguments passing not

Hi,

I use the UAC.nsh to run my installer elevated and at the end launch the exe. Works great, except for one thing. I am passing the args to the installer that I want to have passed down. I am parsing for the ones I want, use MessageBox to verify and then call the UAC function to run "un-elevated". The args are somehow not passed along. Should be as they are in $AppCmdLineParams. Anyone an idea? Here is the function:

Function PageFinishRun
StrCpy $AppCmdLineParams ""

Push "INI" ; push the search string onto the stack
Push "" ; push a default value onto the stack
Call GetParameterValue
Pop $2
MessageBox MB_OK "Value of INI parameter is '$2'"
StrCmp $2 "" 0 +4
MessageBox MB_OK "/INI not found"
Goto +3
MessageBox MB_OK "/INI found. Value '$2'"
StrCpy $AppCmdLineParams "$\"/INI=$2$\" " ; $\" is an escaped double quote character


MessageBox MB_OK "User has choosen to start $INSTDIR\N1MMLogger.net.exe $AppCmdLineParams"
!insertmacro UAC_AsUser_ExecShell "" "$INSTDIR\N1MMLogger.net.exe" $AppCmdLineParams "" ""
FunctionEnd


Andy
AndyJoeB#
I made some more tests. There is definitely a bug or I do not understand whats going on.

With everything being the same this does NOT pass the cmd line argument:

; !insertmacro UAC_AsUser_ExecShell "open" "$theexe" "$ExeCmdParams" "" ""


and this DOES work:
ExecShell "open" "$theexe" "$ExeCmdParams" "SW_SHOW"


Of course the problem is that ExecShell runs elevated, which I am trying to prevent by using UAC_AsUser_ExcecShell.

Does anyone have a clue?

Thanks
Andy
Anders#
Copy $theexe and $ExeCmdParams to one of the standard NSIS registers, you cannot use custom variables because they are not passed to the other non-elevated process...
AndyJoeB#
Thanks.
Just FYI, I found that I can do everything in the un-elevated function, like so:

Function PageFinishRun
!insertmacro UAC_AsUser_Call Function runExe ${UAC_SYNCREGISTERS}|${UAC_SYNCOUTDIR}|${UAC_SYNCINSTDIR} #|${UAC_CLEARERRFLAG}
FunctionEnd

Function runExe
StrCpy $ExeCmdParams ""

Push "INI" ; push the search string onto the stack
Push "" ; push a default value onto the stack
Call GetParameterValue
Pop $2
DetailPrint "Value of INI parameter is '$2'"
StrCmp $2 "" 0 +4
DetailPrint "/INI not found"
Goto +3
DetailPrint "/INI found. Value '$2'"
StrCpy $ExeCmdParams "$\"/INI=$2$\" " ; $\" is an escaped double quote character


DetailPrint "User has chosen to start $\"$INSTDIR\N1MMLogger.net.exe$\" with these arguments $\"$ExeCmdParams$\""
ExecShell "open" "$INSTDIR\.....exe" "$ExeCmdParams" "SW_SHOW"
FunctionEnd

Thanks for the powerful plugin, Anders.

Andy
Anders#
UAC_AsUser_ExecShell also uses UAC_AsUser_Call IIRC. In the beginning the plugin was not designed like this and had internal code for these things but over time people requested new features and rather than coding support for all of them I just made it possible to call a function in the other process.