Working Out Shell Folder Locations

From NSIS Wiki

Author: sunjammer (talk, contrib)


Superseded by: NSIS 2.0 rc1 - New variables.

This example describes how to get a shell folder path not detected by NSIS.


To get the path of a shell folder that is not available using a NSIS variable you should read from

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

or HKEY_LOCAL_MACHINE for the all users version.


Here's an example that get you the Application Data folder. It will first try to get the current user's folder, then all users', and if not found, it will give the default ($WINDIR\Application Data):

  "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
ReadRegStr $0 HKCU "${SHELLFOLDERS}" AppData
StrCmp $0 "" 0 +2
  ReadRegStr $0 HKLM "${SHELLFOLDERS}" "Common AppData"
StrCmp $0 "" 0 +2
  StrCpy $0 "$WINDIR\Application Data"

Attention: This does not work on german windows (tested: x64 with english language)!

Personal tools