Archive: How can I make setup path only select drivers?


How can I make setup path only select drivers?
I only want install to path example " c:\abc " or "d:\abc" or "e:\abc" or "f:\abc".


You mean drives not drivers right?

You can use this function to retrieve a list of hard drives on the system.
http://nsis.sourceforge.net/GetDrives
You could write the list to an InstallOptions list box control, or use my PopupListBox/EmbeddedLists plugins to display list boxes (both on the Wiki).

-Stu


This is probably 'root install only' situation. You can set default folder as "c:$\abc", add 'root install only' item to existing page controls or using Marquee plug-in and check resulting $INSTDIR in the dirpage leave function (or .onVerifyInstDir function, but this may looks crazy) for root folder and blank spaces.


I only want install to path example " c:\abc " or "d:\abc" or "e:\abc" or "f:\abc".
The following example should install on 'X:\abc'.
* X = the root of the system drive (the drive where the operation system is installed).

name 'test abc dir'
outfile 'test.exe'
showinstdetails show

page directory
page instfiles verify_abc

function .onInit
strcpy '$R0' '$SYSDIR' 3
strcpy '$INSTDIR' '$R0abc'
functionend

section -
Setoutpath '$INSTDIR'
# do what you have to do
Setoutpath '$INSTDIR\MyAPP'
# do what you have to do
Setoutpath '$INSTDIR\So Long'
# do what you have to do
sectionend

function verify_abc
strcpy '$R0' '$SYSDIR' 3
strcmp '$R0abc' '$INSTDIR' +3 +1
strcpy '$INSTDIR' '$R0abc'
messagebox mb_ok 'reseting output directory to $R0abc'
functionend

To get the root drive, just do:

StrCpy $R0 $SYSDIR 1

$R0 == "C" or "D" etc

-Stu


thanks!

Cant U give .nis full example ?


Cant U give .nis full example ?
The above example is a full working one. Just copy/paste to editor's window and test it. If you like a more scriptable look :-) then define the default dir !define DEFAULT_DIR 'abc' and change the code according to the define ($R0abc becomes ${DEFAULT_DIR}. Just remember that, this example detects the system drive, if you plan to install on others, you should try GetDrives (Nsis Users Manual E.1.5 GetDrives).