NSIS problem accessing data

萝らか妹 提交于 2019-12-11 07:23:54

问题


I'll try to make myself as clear as possible.

I made an installation program with NSIS. An icon was created on the desktop and when I double-click it, the application lanches well. However, in the install directory I have other directories (like "css" which contains "style.css"), and it seems that the program is looking for my css file in the directory of the shortcut (-> desktop).

How could I make the program looking in the install directory rather than in the desktop ?

Thanks for your answers.


Here is the code I used :

Section "Shortcuts"
SectionIn 2 
SetOutPath "$SMPROGRAMS\MyApp"
CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe"
SectionEnd 

If I change the outpath (line 3) to "$INSTDIR", the shortcut isn't created at all. If I use this code, the shortcut is created but the "start in" parameter is set to the desktop.


回答1:


The problem in this case is that your application is using relative paths without qualifying them; the simple solution is to have the shortcut specify the working directory: (it seems strange that the SetOutPath alters the CreateShortCut, but the manual says it does)

SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe" # etc.

The proper solution is to make all paths absolute; you've tagged it as qt so I presume you're using Qt and C++. Search around for "qt absolute path" and things like that - e.g. Qt-interest Archive - How to get an application's absolute path?




回答2:


Section "Shortcuts"
SectionIn 2 
CreateDirectory "$SMPROGRAMS\MyApp" #CreateShortCut does not create directories
SetOutPath "INSTDIR"
CreateShortCut "$SMPROGRAMS\MyApp\MyApp.lnk" "$INSTDIR\MyApp.exe"
SetOutPath "$INSTDIR"
CreateShortCut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe"
SectionEnd 


来源:https://stackoverflow.com/questions/4244895/nsis-problem-accessing-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!