Archive: how to check if the disk on which to install the software exists


how to check if the disk on which to install the software exists
For a small piece of software and some data files I have to check first if the target disk (D:) exists. If not, then install the software on the c: disk.

Is there any way to perform this?
I have tried ifileexist, but I get compile errors.
Searching the discussion I couldnot find a solution.

Please help?
Thanks.


Does the software wrote registry keys or
have a pre-defined installation path?


Firstly you can check if the D or C drives exist first like so:

IfFileExists "D:\" +2
MessageBox MB_OK "D: drive does not exist" ID_OK done1

## place search !insertmacro here ##

done1:
IfFileExists "C:\" +2
MessageBox MB_OK "C: drive does not exist" ID_OK done2

## place search !insertmacro here ##

done2:


The search function is here:
http://nsis.sourceforge.net/archive/...ances=0,11,211

-Stu

Thanks for your reply.

First the software does not write registry keys. The goal is to do a silent install. When for the first time we do an install the installer checks 1) for the D: disk and if not present uses the C: disk.


The second or the next time an update of the usersoftware is needed, we do the same check. The installation directories have always the same name and structure.

Does this help to use the proposed solution.?

regards, jan willem


Use my example.

It may need modifying.
I would modify it for you but my thinking head is still asleep at the moment :(

-Stu


Stu, I would be much obliged, if you could modify it.

Thanks in advance
jan willem


Ok, I have my mind in gear a bit more now lol
No need for search functio nat all.


IfFileExists "D:\" 0 install_on_c
DetailPrint "Installing software to D: drive"

## place files here ##

Goto done
install_on_c:
DetailPrint "Installing software to C: drive"

## place files here ##

done:


-Stu

Many thanks Stu,
With a small modification, this works OK.

The IfFileExists needs a *.* to check for the D: disk.

code:--------------------------------------------------------------------------------
IfFileExists "D:\*.*" 0 install_on_c
DetailPrint "Installing software to D: drive"

## place files here ##

Goto done
install_on_c:
DetailPrint "Installing software to C: drive"

## place files here ##

done:
--------------------------------------------------------------------------------