简体   繁体   中英

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?

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

You can use GetKnownFolderPath :

GetKnownFolderPath $0 {62AB5D82-FDC1-4DC3-A9DD-070D1D495D97} ; FOLDERID_ProgramData
MessageBox MB_OK $0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM