Skip to content
⌘ NSIS Forum Archive

RequestExecutionLevel admin causes no creation of folders in directory page possible

4 posts

andi2401#

RequestExecutionLevel admin causes no creation of folders in directory page possible

Hey everybody.

I am trying to build an NSIS installer with using Modern UI.

I need admin rights, especially for writing to HKLM. So I used

RequestExecutionLevel admin
to use admin rights. When starting installer, Windows asks for confirmation of admin privileges, so everything seems fine. Writing to HKLM is also possible.

But no the problem is: In the directory page, I tried to create a new folder on many places, but no where it is possible. A message box in the dialog pops up with german message: "Sie können hier keinen neuen Ordner erstellen. Wählen Sie einen anderen Ort aus." By the way: The rest of my installer is in english. So it seem, that on the directory page, there are no rights for creating folders. When I try to create a folder in the script, everything works and I am wondering why.

Also creating folders everywhere with user privilges is possible.

Any ideas for a solution of this strange problem?
Anders#
Are you talking about the "folder tree selection dialog" you get when you click the browse button on the directory page? This is SHBrowseForFolder provided by Windows.

Windows version? NSIS Version?
andi2401#
Exactly, this is the dialog I have problems with.

I use NSIS 3.11 on Windows 11 Enterprise 23H2.

I tested on another machine with Windows 11, same problem.

Machine with Windows 10 -> no problems.

Maybe this is a Windows-11-specific problem?
Anders#
With "RequestExecutionLevel Admin", what happens if you try to create a folder where you don't need admin access like desktop or documents? What if you use "RequestExecutionLevel User"?

What about this?
RequestExecutionLevel Admin
!include LogicLib.nsh
Section
again:
System::Call KERNEL32::lstrcpy(@r1,w"")
!define BIF_RETURNONLYFSDIRS 1
!define BIF_NEWDIALOGSTYLE 0x40 # If you change "0x40" to "0", the "new folder" button probably goes away.
System::Call '*$1(p$hWndParent, p0, p0, w "Hello", i ${BIF_RETURNONLYFSDIRS}|${BIF_NEWDIALOGSTYLE}, p0, p0, i0)'
System::Call 'SHELL32::SHBrowseForFolderW(p$1)p.r0'
${If} $0 P<> 0
    System::Call 'SHELL32::SHGetPathFromIDListW(pr0, w"?"r2)'
    MessageBox MB_OK "You picked $2"
    System::Call 'SHELL32::SHFree(pr0)'
    Goto again
${EndIf}
Quit
SectionEnd