Search code examples
nsissetup-deployment

NSIS How to create Symbolic linked junction-points files/folders at run-time


I am trying to figure out how to get my NSIS setup script to create a directory which will be a junction point to another folder/directory

I have my application which I am building an installer for which already contains junction-points in its file-system, I am now trying to package up into my NSIS installer by creating each directory and file as represented in my application build folder (junctions included).

I would prefer not to use a batch script (as a simple fix) to carry out this step, which I could have the NSIS setup execute during runtime to setup the mklink on the directory(s) as required.

I would much rather find out if there is a proper way to achieve this purely from within NSIS setup script itself.

for simplicity sake here is a brief example of what I wish to achieve:

...
section

CreateDirectory "$INSTDIR\folder0\Logs"    # <-- This is the actual dir.
CreateDirectory "$INSTDIR\folder1\Logs"    # <-- This should be junction of ..\folder0\Logs

sectionend
...

Also I would like to know if it is possible to carry out the same operation of creating a hard-linked junction directory except this time for a file instead.

I am a NSIS installer newbie and as yet have not fully understand what NSIS is capable of achieving with regards to file/folder manipulation. NSIS does look to be very flexible and powerful enough for my needs thus far.

edit I would just like to see the basic principle on how to create a Junction-Link from within NSIS.


Solution

  • NSIS does not have native support for any advanced filesystem features but you can call any API with the system plugin: Symbolic Links, Junctions, Hard Links