Old 6th December 2006, 20:08   #1
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
Question Not allow users to change app directory

HI its me again
Following the suggestions of this forum I ask for a new problem
I dont want to allow user to select the directory of the application and I need now to create 2 different directories depending on the options that are selected, until everything what I saw in the samples uses
SetOutPath $INSTDIR\MyApp
How I make to create for example \MyApp and \MyApp2 ?
Boyito is offline   Reply With Quote
Old 6th December 2006, 21:00   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Use LogicLib.

-Stu
Afrow UK is offline   Reply With Quote
Old 6th December 2006, 21:20   #3
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Examine this test:
code:
outfile 'Components_test.exe'
InstallDir '$PROGRAMFILES\Components Test'

!include 'mui.nsh'

!insertmacro MUI_PAGE_COMPONENTS
# no dir page
#!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

section "!Required Section"
SectionIn RO
SetOutPath '$INSTDIR'
SectionEnd

Section "Components 1"
SetOutPath '$INSTDIR\Component 1'
SectionEnd

Section /o "Components 2"
SetOutPath '$INSTDIR\Component 2'
SectionEnd


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 7th December 2006, 13:06   #4
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
Thanks Red Wine
But now my answer is, exist a way to create directories under the ROOT of the Disc and not under $PROGRAMFILES??

TIA
Boyito is offline   Reply With Quote
Old 7th December 2006, 15:03   #5
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
Here is an example on how to create installation directories on the drive where windows are installed :-)
E.g. if it is D:\WINDOWS the installation is going to D:\My Test etc.
code:
!define DEFAULT_DIR 'My Test'

outfile 'test.exe'
showinstdetails show
InstallDir '$PROGRAMFILES\${DEFAULT_DIR}'

page license
page directory dir_pre
page instfiles

function dir_pre
strcpy '$R0' '$WINDIR' 3
strcpy '$INSTDIR' '$R0${DEFAULT_DIR}'
functionend

section -

Setoutpath '$INSTDIR'

Setoutpath '$INSTDIR\MyAPP'

Setoutpath '$INSTDIR\My App More'

sectionend


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 7th December 2006, 16:40   #6
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
Thank You RW, this solve my problem

Bye
Boyito is offline   Reply With Quote
Old 7th December 2006, 17:06   #7
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
RW
Sorry its me again

When i compile trying to use your tip, shows me an error

This is a part of code :

--------------------------------------------
!define DEFAULT_DIR 'MyApp'

!include "MUI.nsh"

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(MUILicense)
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY dir_pre
--------------------------------------

And the error

!insertmacro: macro "MUI_PAGE_DIRECTORY" requires 0 parameter(s), passed 1!
Error in script "IpReader.nsi" on line 58 -- aborting creation process

--------------------------------------------

Whats wrong?
Boyito is offline   Reply With Quote
Old 7th December 2006, 18:20   #8
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
The example above is about classic UI. For MUI here it is:
code:
!define DEFAULT_DIR 'My Test'

outfile 'test.exe'
showinstdetails show
InstallDir '$PROGRAMFILES\${DEFAULT_DIR}'

!include 'mui.nsh'

!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_PRE dir_pre
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_PAGE_CUSTOMFUNCTION_PRE verify_default_dir
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

function dir_pre
strcpy '$R0' '$WINDIR' 3
strcpy '$INSTDIR' '$R0${DEFAULT_DIR}'
functionend

section - "a hidden section"
Setoutpath '$INSTDIR'
sectionend

section /o "Section MyApp"
Setoutpath '$INSTDIR\MyAPP'
sectionend

section /o "Section My App More"
Setoutpath '$INSTDIR\My App More'
sectionend

function verify_default_dir
strcpy '$R0' '$WINDIR' 3
strcmp '$R0${DEFAULT_DIR}' '$INSTDIR' +3 +1
strcpy '$INSTDIR' '$R0${DEFAULT_DIR}'
messagebox mb_ok 'reseting output directory to $R0${DEFAULT_DIR}'
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 7th December 2006, 18:26   #9
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
Ups, sorry
Thanks i try with this one
Boyito is offline   Reply With Quote
Old 7th December 2006, 19:03   #10
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
Hi RW
I try and doesnt work in the way I need.
It generates a C:\My Test\MyApp directory to me and a C:\My Test\MYapp\My App More
In addition never shows the message to me of messagebox mb_ok “reseting output directory to $R0$ {DEFAULT_DIR}”
I need to create C:\My App and C:\My App More

Any idea ?
Boyito is offline   Reply With Quote
Old 7th December 2006, 19:22   #11
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
1. you'll see the message if you attempt to change the default dir, remove it, probably you don't need that.
2. feel free to modify the skeleton script to suit your needs. add/remove sections, change dirs etc.
EXAMPLE:
code:
outfile 'test.exe'
showinstdetails show
AllowRootDirInstall true

!include 'mui.nsh'

!insertmacro MUI_PAGE_WELCOME
!define MUI_PAGE_CUSTOMFUNCTION_PRE dir_pre
; no dir page
; !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"

function dir_pre
strcpy '$R0' '$WINDIR' 3
strcpy '$INSTDIR' '$R0'
functionend

section - "Section MyApp"
Setoutpath '$INSTDIR\MyAPP'
sectionend

section - "Section My App More"
Setoutpath '$INSTDIR\My App More'
sectionend


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 7th December 2006, 19:44   #12
Boyito
Senior Member
 
Join Date: Nov 2006
Location: Argentina
Posts: 142
Thanks RW
It Works as i need
Thank you very much
Now I have another problems, but I am going to ask them in new post
Thanks for your time
Boyito is offline   Reply With Quote
Old 8th December 2006, 16:29   #13
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
You welcome :-)
Just remember that the above, used in function dir_pre code, it's a trick just to give us the drive letter of the disk where windows are installed.
If you wish to install on other media, network drives etc, you have to refer to the included GetRoot, GetDrives etc.

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