[英]Change the default install folder in NSIS
I'm writing a installer for windows using nsis. 我正在使用nsis编写Windows安装程序。 This installer contains a web application which is run on top of xampp, so xampp is also installed as a service with this application.
此安装程序包含一个在xampp之上运行的Web应用程序,因此xampp也作为此应用程序的服务安装。 But xamp gives an issue when it installed in 64bit machine on Windows 7. This is due to the directory path issue in C:\\Program Files (x86) as mentioned here.
但是xamp在Windows 7上安装在64位机器上会出现问题。这是由于此处提到的C:\\ Program Files(x86)中的目录路径问题。
XAMPP Error Solution? XAMPP错误解决方案? I have that installed on my Windows XP Dual Boot Machine
我已经在我的Windows XP双引导机上安装了它
But currently the automatic installation path is set as follows in the installer. 但是目前自动安装路径在安装程序中设置如下。
C:\Program Files (x86)\myapplication
The installer script just have the following macro to add the directory chooser page. 安装程序脚本只有以下宏来添加目录选择器页面。
!insertmacro MUI_PAGE_DIRECTORY
As a solution what I'm going to do are following actions. 作为一种解决方案,我要做的就是采取行动。
For that I need to get the install directory path by 为此,我需要获取安装目录路径
$INSTDIR
and 和
Since I'm not much familiar with nsis I'm unable to write this program. 由于我对nsis不太熟悉,我无法编写这个程序。
Can someone help me on this issue? 有人可以帮我解决这个问题吗?
NSIS提供$ PROGRAMFILES32和$ PROGRAMFILES64:
InstallDir "$PROGRAMFILES64\myapp"
On a win7/64, the 64 bits program files can be get from a 32 bit application via the %ProgramW6432%
environment variable. 在win7 / 64上,可以通过
%ProgramW6432%
环境变量从32位应用程序获取64位程序文件。
You could try to get it with ReadEnvStr
: 您可以尝试使用
ReadEnvStr
获取它:
c:\\program files
(if not configured elsewhere) c:\\program files
(如果未在其他地方配置) Here is a snippet that test it : 这是一个测试它的片段:
ReadEnvStr $0 ProgramW6432
StrCmp $0 "" 0 +3
MessageBox MB_OK "it is a 32b system"
goto +2
MessageBox MB_OK "it is a 64b system"
In your case, it could do : 在你的情况下,它可以做:
ReadEnvStr $0 ProgramW6432
StrCmp $0 "" +2 0
StrCpy $INSTDIR $0
Edit : For the point to refuse Program Files (x86)
you could use the .onVerifyInstDir
callback method that was given by Anders for another question , it will check the choosen directory as it is selected by the user and before changing the page : 编辑 :对于拒绝
Program Files (x86)
的点,你可以使用Anders给出的另一个问题的.onVerifyInstDir
回调方法,它会检查用户选择的选择目录,然后再更改页面:
Function .onVerifyInstDir
ReadEnvStr $0 "ProgramFiles(x86)"
StrCmp $0 $INSTDIR 0 PathGood
MessageBox MB_OK "directory not valid for installation"
Abort
PathGood:
FunctionEnd
Here, I use another environment variable to get the (x86) variant of program files. 在这里,我使用另一个环境变量来获取程序文件的(x86)变体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.