Hello all!
I am new on NSIS.
I want to verify if the install selected directory (Destination Folder) is on the same disk unit as ’My Documents’ folder and to force the user to install the files in a folder located on this disk unit. In case of error (if user try to install the files on other one disk unit but ’My Documents’ disk unit): an error message on screen, focus on ’Destination folder’ and ’Next’ button disabled.
If anyone has done this or has an example, it would be appreciated.
Thanks you in advance for assistance.
Install files on 'My Documents' disk drive unit
12 posts
This seems like a really stupid requirement.
This is not as simple as you might think because you might have to handle symlinks and junctions! Do you want it to be on the same partition or just the same drive letter?
This is not as simple as you might think because you might have to handle symlinks and junctions! Do you want it to be on the same partition or just the same drive letter?
Thank You Anders for you answer.
I'll try to be more specific.
The files installed by the installer are: a program written in AutoLisp (.vlx file), an user interface dialog (.DCL file) for AutoLisp program, a Help file (.chm file), two .EXE files written in AutoHotKey language, a Readme.txt file and two .PDF files. VLX software can be used under a CAD editor (AutoCAD, ZWCAD etc.).
Well... In order to customize the program, I used three levels of security: user name, serial number of CAD editor serial number of hard disk. These data I receive from the user which runs a program for gathering information (program included in the demo version).
However, it seems a good practice to make the installation program on a given disk drive. On the other hand, the program does not work if installed on a different drive than the one that is installed the CAD editor. The editor executable file name differs, depending on the editor used. Eg for AutoCAD is called acad.exe. In a network environment it is always on the drive unit which is the "My Documents" user folder.
On Directory page settings I wrote a Warning regarding Installation Folder (see attached file 1.gif).
I'll try to be more specific.
The files installed by the installer are: a program written in AutoLisp (.vlx file), an user interface dialog (.DCL file) for AutoLisp program, a Help file (.chm file), two .EXE files written in AutoHotKey language, a Readme.txt file and two .PDF files. VLX software can be used under a CAD editor (AutoCAD, ZWCAD etc.).
Well... In order to customize the program, I used three levels of security: user name, serial number of CAD editor serial number of hard disk. These data I receive from the user which runs a program for gathering information (program included in the demo version).
However, it seems a good practice to make the installation program on a given disk drive. On the other hand, the program does not work if installed on a different drive than the one that is installed the CAD editor. The editor executable file name differs, depending on the editor used. Eg for AutoCAD is called acad.exe. In a network environment it is always on the drive unit which is the "My Documents" user folder.
On Directory page settings I wrote a Warning regarding Installation Folder (see attached file 1.gif).
I fogot the GIF file. See attachment. Sorry!
You have two options.
A) Inspect $InstDir in the directory leave callback function and display a MessageBox and call Abort so it does not move to the next page.
B) Use .onVerifyInstDir
A) Inspect $InstDir in the directory leave callback function and display a MessageBox and call Abort so it does not move to the next page.
B) Use .onVerifyInstDir
Thank you Anders
Can you send me the code, please?
Can you send me the code, please?
How could I possibly do that when you did not specify which behavior you want. This forum is not a code writing service, we expect you to at least try to write it yourself first.Originally Posted by LiDo View PostThank you Anders
Can you send me the code, please?
Dear Anders,
All that I want is to compare the first letter of $INSTDIR with the first letter of $DOCUMENTS (no message!). If true, go on. If false grey the button Next. I don't know how to do that.
I tried with ${StrTok} from StrFunc.nsh but didn't work.
All that I want is to compare the first letter of $INSTDIR with the first letter of $DOCUMENTS (no message!). If true, go on. If false grey the button Next. I don't know how to do that.
I tried with ${StrTok} from StrFunc.nsh but didn't work.
I wrote that and it seems to work fine. The button Next is grayed even if edit the installation folder string or Browse button.
Function .onVerifyInstDir
StrCpy $0 '$INSTDIR' 1
StrCpy $1 '$DOCUMENTS' 1
Pop $0
Pop $1
${If} $0 != $1
Nop
Abort
${EndIf}
FunctionEnd
A better solution?
Function .onVerifyInstDir
StrCpy $0 '$INSTDIR' 1
StrCpy $1 '$DOCUMENTS' 1
Pop $0
Pop $1
${If} $0 != $1
Nop
Abort
${EndIf}
FunctionEnd
A better solution?
x:\mydocuments might not be on the same volume as x:\whatever. If you want to know more about this you can Google NTFS junctions and mount points...
Thank you Anders for information.
I just read the article.
Sa, what to do (by using NSIS) if the user mounted "My Document" folder to another drive letter?
I just read the article.
Sa, what to do (by using NSIS) if the user mounted "My Document" folder to another drive letter?
A drive letter is always the root and a volume is mounted there, the issue is that you can mount another volume as a folder. (Mount point)Originally Posted by LiDo View PostThank you Anders for information.
I just read the article.
Sa, what to do (by using NSIS) if the user mounted "My Document" folder to another drive letter?
You can also create a junction (acts like a folder) to another drive letter or a folder on a different volume. Try Mklink.exe or download junction from sysinternals...