Reputation: 3
I have an electron app, I want the default installation path to be D: if it exist, instead of C:
My current installer.nsh file is:
Section
System::Call 'kernel32::GetFileAttributes(t "D:\")i .r0'
IntCmp $0 -1 NoDInstalled DriveDInstalled
NoDInstalled:
StrCpy $INSTDIR "$PROGRAMFILES\"
Goto ContinueInstallation
DriveDInstalled:
StrCpy $INSTDIR "D:\"
Goto ContinueInstallation
ContinueInstallation:
SetOutPath $INSTDIR
SectionEnd
I have a D: external drive connected to my computer and the default is still C:
Would love some help!
Upvotes: 0
Views: 151
Reputation: 101569
$InstDir
in .onInit
, not in a Section
.IntCmp
.$PROGRAMFILES
!macro customInit
System::Call 'kernel32::GetFileAttributes(t "D:\")i.r0'
${If} $0 <> -1
StrCpy $INSTDIR "D:\"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\$(^Name)"
${EndIf}
!macroend
In real NSIS you would just
Function .onInit
!insertmacro customInit
FunctionEnd
but since you are using electron I have no idea where you actually put this macro, the documentation is not clear if it is in installer.nsh or somewhere else. Their code makes it look like it should be somewhere else, you probably have to ask them directly for support if you can't figure it out yourself.
Upvotes: 0