windows-installernsis

install in ProgramData folder using NSIS


I'd like to install some application data in C:\ProgramData folder using nsis installer. I'd like to avoid hardcoding it, because it may not be on C: drive.

The documentation https://nsis.sourceforge.io/Docs/Chapter4.html doesn't have any constant that defines ProgramData. What is the nsis way of installing in ProgramData folder?


Solution

  • Microsoft moved and renamed some of the special folders in Vista. %ProgramData% is CSIDL_COMMON_APPDATA and you can get that path in NSIS:

    Section
    SetShellVarContext all
    MessageBox MB_OK "$LocalAppData"
    SetOutPath "$LocalAppData\MyAppsData" 
    File /r mydata\*.*
    SectionEnd