Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 31st December 2006, 13:38   #1
ontrack16
Junior Member
 
Join Date: Dec 2006
Posts: 4
Question How to set the installation directory depending on a choice user made earlier ?

A user can select either installation locally or on a network.

When the user selects local, the install dir should be by default eg C:\Install.
When the user selects network, the install dir should be by defalt eg F:\Install.

When I call the Directory page however, I can't get to set the right default installation directory.

The directory page uses InstallDir and I can't change the value of that InstallDir from inside a section/function.
ontrack16 is offline   Reply With Quote
Old 31st December 2006, 13:51   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
The directory page uses InstallDir and I can't change the value of that InstallDir from inside a section/function.
You can't do that. InstallDir means the suggested default directory that installer adds on directory page.
It'd change once users hit the browse button and specify another directory.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 31st December 2006, 14:06   #3
ontrack16
Junior Member
 
Join Date: Dec 2006
Posts: 4
I think I got it.
There was already a topic with title : "overwrite default InstallDir"

I will use the same technique.
Sorry for asking the same question twice.
ontrack16 is offline   Reply With Quote
Old 31st December 2006, 14:22   #4
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
If you want to show a suggested dir on directory page different than the one specified with InstallDir then you should do something like this:
code:
Name "My Application"
OutFile test.exe
LicenseData '${NSISDIR}\License.txt'
LicenseBkColor 0xFFFFFF
InstallDir '$PROGRAMFILES\$(^name)'

!include winmessages.nsh

Page License
Page Components
Page Directory '' dir_show
Page InstFiles

Section "boo"
######
SectionEnd

Function dir_show

FindWindow $R1 "#32770" "" $HWNDPARENT
GetDlgItem $R2 $R1 '1019'
ExpandEnvStrings $R0 '%USERPROFILE%'
SendMessage $R2 ${WM_SETTEXT} 1 'STR:$R0\$(^name)'
GetDlgItem $R2 $HWNDPARENT 1
System::Call "user32::SetFocus(i R2)i"

FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 1st January 2007, 11:03   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Quote:
When the user selects local, the install dir should be by default eg C:\Install.
When the user selects network, the install dir should be by defalt eg F:\Install.
You're able to achieve this only in Function .onInit.
However you must use messageboxes to interact with users since there is no GUI yet.
EXAMPLE:
code:
Name "My Application"
OutFile test.exe
LicenseData '${NSISDIR}\License.txt'
LicenseBkColor 0xFFFFFF
InstallDir '$PROGRAMFILES\$(^name)'

Page License
Page Components
Page Directory
Page InstFiles

Section "boo"
;;;;;;;;;
SectionEnd

Function .onInit
StrCpy $0 0
EnumRegKey $1 HKCU Network $0
StrCmp $1 "" end ;there is no network drive mapped
;found mapped drive(s) ask user if install either on local or network
MessageBox MB_ICONQUESTION|MB_YESNO \
"Install on local or Network drive?$\n$\n\
Either select Yes for local or No for network" IDYES end ;user selection is local installation

EnumRegKey $1 HKCU Network $0
StrCpy '$R0' '$1:'
IntOp $0 $0 + 1
EnumRegKey $1 HKCU Network $0
StrCmp $1 "" done ;there is only one mapped net drive we shall use this

StrCpy $0 0

loop: ;find all available network drives and promt user to select one
EnumRegKey $1 HKCU Network $0
StrCpy '$R0' '$1:'
IntOp $0 $0 + 1
EnumRegKey $1 HKCU Network $0
StrCmp $1 "" last
MessageBox MB_YESNO|MB_ICONQUESTION \
"Install on $R0 network drive?$\n$\n\
Select Yes to install on $R0, No to select another drive" IDYES done
goto loop

last:
MessageBox MB_YESNO|MB_ICONQUESTION \
"Last network drive found $R0 install here?$\n$\n\
Select Yes to install on $R0, No to start over" IDYES done
StrCpy $0 0
goto loop

done:
StrCpy '$INSTDIR' '$R0\$(^name)'

end:
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump