Symlink - different methods to do it or how to keep your C drive unclutered)

Discussion in 'Software' started by Olymoon, Feb 25, 2020.

  1. Olymoon

    Olymoon Moderator

    Joined:
    Jan 31, 2012
    Messages:
    5,801
    Likes Received:
    4,465
    As the title says, let's share different way to create symlink and use it.

    These is one method that was explained by an AudioZ member:
    It's very easy to do
    How to do a symlink, example: green where it should be - blue where you want it to be
    1 Copy the address of the folder that you want to replace by a symlink, to a text file.

    2 Copy this folder where you want it to be
    3 Delete this folder where it was (if folder is still there, symlink commend will not work)

    In an elevated command prompt (Typo cmd in windows start search bar):
    Write
    mklink /d "C:\ProgramData\Sonic Academy" "X:\Sonic Academy"

    And that's it...
    .....

    These are other methods using tools:
    From @The Pirate
    From @Pereira
    From @Zikkk

    Please, if you know any method and or tool, feel free to add it in the comments
    I'm also looking to how to link to a file instead of a folder

    Thanks
     
    Last edited: Dec 1, 2020
    • Useful x 10
    • Like x 4
    • Interesting x 2
    • Winner x 1
    • Love it! x 1
    • List
  2.  
  3. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,986
    Likes Received:
    3,859
    Location:
    Europe
    Foldermove is like a special case similar to that "Ultimate plugin tool" feature. But if you only need that seems cool.

    LinkShellExtension does that and much more. Just looking at the documentation it explains all there is to symlink, hardlinks, etc.
    You can do the same on the command line, but that's harder to remember and more for server admin use (Linux, Windows servers,...).

    One thing that may break your stuff are folder and files permissions. Can be easily solved, you just have to apply the same ones of the original folder. I've only once got that problem with audio software though.

    In order to link to a file you must use a hardlink or symlink (not a junction).
    Edited: For Windows and this kind of uses, I would recommend symbolic links for files before hard links. The main reason is that hard links don't support pointing to other partitions or beyond (network, ...)
    For folders, junction links.
     
    Last edited: Feb 25, 2020
    • Agree Agree x 2
    • Interesting Interesting x 2
    • Like Like x 1
    • Useful Useful x 1
    • List
  4. LV4-26

    LV4-26 Guest

    • Interesting Interesting x 2
    • List
  5. DoubleTake

    DoubleTake Audiosexual

    Joined:
    Jul 16, 2017
    Messages:
    2,195
    Likes Received:
    1,151
    One thing that would be nice is for any folder that is Symlinked to have some special color in Windows.
    That would be nice for people who are moving (or renaming) folders a lot.
    Symbolic Links themselves are colored and Link Shell Extension gives option to customize the look, but the folders they point to get no special color.


    If I move (or rename) a folder, I assume the program will prompt for the location and I do that for all that will prompt me.|
    But if I have SymLinked a folder, that usually means the program does not prompt for the location if the folder is moved (or renamed).
    In that case I should make a new Symlink pointing to where I move (or rename) the folder.

    I have begun just making a text file that says "Symlinked.txt", so I can see which folders are normal and which are linked.
    I suppose I could customize each folder, but a common "SymLinked" overlay arrow would be cool.
     
  6. redhead

    redhead Member

    Joined:
    Nov 22, 2013
    Messages:
    27
    Likes Received:
    7
    Hey Oly.... I've always been intrigued by these symlinks I see and have not fully understood them, but your post intrigued me so I'm doing a little research myself now to try and get acclimated.

    Some posts I've read say that you need to use /h to link to a file (a hard link)....but others say /d defaults to file links (rather than folder links)... Have you tried both commands without success? :dunno:
     
    • Interesting Interesting x 1
    • List
  7. AirTracK

    AirTracK Member

    Joined:
    May 26, 2018
    Messages:
    15
    Likes Received:
    8
    Location:
    San Jose, CA
    So anyone with Symlink knowledge can help me answer this question :

    If I use Folder Move or LinkShellExtension to move my folders, can I erase the original folder? And then proceed to use the new Symlink folder to start my program as usual?

    Thanks.
     
  8. Olymoon

    Olymoon Moderator

    Joined:
    Jan 31, 2012
    Messages:
    5,801
    Likes Received:
    4,465
    Yes, that's the purpose of symlink :yes:
     
  9. Olymoon

    Olymoon Moderator

    Joined:
    Jan 31, 2012
    Messages:
    5,801
    Likes Received:
    4,465
    Interesting. No I haven't tried this, but I will, thank you.
     
  10. Olymoon

    Olymoon Moderator

    Joined:
    Jan 31, 2012
    Messages:
    5,801
    Likes Received:
    4,465
    You could change the folder icon to a colored one.
     
  11. demberto

    demberto Rock Star

    Joined:
    Nov 27, 2018
    Messages:
    931
    Likes Received:
    325
    If you want to do it in cmd, with admin privileges you can use, it will create a fully UNIX/Linux compatible symlink. This is for windows vista and above:

    rundll32 kernel32.dll,CreateSymbolicLinkW SYMLINK_NAME, TARGET_ADDRESS, FLAG

    SYMLINK_NAME is the name of the link to be created. TARGET_ADDRESS is the address of the file or directory whose symlink is to be created. FLAG should be set to 0 if a file is to be symlinked and 1 if a directory(folder) is to be symlinked. Use the CreateSymbolicLinkA function if you are on XP. Note that this is different from hard links and junctions. Relative links can be made as well. Refer here for naming schemes. This will return 0 if operation fails.
     
  12. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,986
    Likes Received:
    3,859
    Location:
    Europe
    I think that's for C/C++ programs, not command line
     
  13. Xupito

    Xupito Audiosexual

    Joined:
    Jan 21, 2012
    Messages:
    6,986
    Likes Received:
    3,859
    Location:
    Europe
    You're right. Some of these famous "no install" .cmd files that use symlinks (usually junctions) have annotated the affected folders like you say.

    As far as I know only hard links "follow" the "symlinked" file even if you move it, but they're not the ones we want to use for this.
    I would advice to do just what these no installs do.

    In every folder you want to "symlink" create a .cmd file to make and another to delete:
    create_symlink.cmd:
    cmd /c mklink /j "C:\Program files\Blue Cat Audio" "%~dp0Blue Cat Audio" // The latter is the "symlinked"
    delete_symlink.cmd:
    cmd /c rmdir "C:\Program files\Blue Cat Audio"



    Why this helps? Because if you move the "symlinked" folder you only have to execute delete_symlink and create_symlink.

    In fact in my "no installs" I always delete just in case before creating the symlink:
    create_symlink.cmd:
    cmd /c rmdir "C:\Program files\Blue Cat Audio"
    cmd /c mklink /j "C:\Program files\Blue Cat Audio" "%~dp0Blue Cat Audio" // The latter is the "symlinked"

    delete_symlink.cmd:
    cmd /c rmdir "C:\Program files\Blue Cat Audio"

    Note: rmdir only deletes empty folders by default. That includes symlinks. You won't break anything
     
    Last edited: Feb 29, 2020
  14. Pagurida

    Pagurida Producer

    Joined:
    Nov 30, 2012
    Messages:
    196
    Likes Received:
    149
    Location:
    Brain
    Just another little subtlety:
    I prefer mklink /j instead of mklink /d because /j works also when accessing from another computer in the network, while /d always refers back to the local PC.

    Example:
    A junction point (option /j) c:\myjp and a directory symbolic link (option /d) c:\mysymlink are created on a computer Alfa.
    Both refer to the target folder c:\targetfolder.
    On Alfa, you will recognize no difference, but you will on Beta, another PC in the network:
    - The junction point \\Alfa\c$\myjp points correctly to \\Alfa\c$\targetfolder
    - The symbolic link \\Alfa\c$\mysymlink however erroneously points to \\Beta\c$\targetfolder
    The latter often causes an access error when you try to open the folder.
     
    Last edited: Mar 1, 2020
    • Agree Agree x 1
    • Interesting Interesting x 1
    • List
  15. Stryves

    Stryves Platinum Record

    Joined:
    Feb 22, 2020
    Messages:
    389
    Likes Received:
    275
    If you use symlinks with multiple drives please don't go to hard drives from SSD. Have a 2nd SSD. Maybe for some stupendous large libraries it's tempting to use a HDD but even then use SSD for the stuff that needs symlink and HDD for garbage/rarely used stuff

    I setup 2x SSD for my nephew cause he ran out of space and he doesn't even realize I just grabbed another drive for him.
     
    Last edited: Mar 1, 2020
  16. chumbo

    chumbo Ultrasonic

    Joined:
    Mar 2, 2017
    Messages:
    125
    Likes Received:
    32
    I'm a bit confused...
    Unless I missed it in this thread, nobody has made mention of the necessity of first installing the software that we want to create a symlink for but I'm guessing that's step 1, right? (maybe not mentioned because it's so obvious to everyone...not me :disco:).

    Then, the other thing I wonder about is, a "normal" software will by definition not be self-contained to just it's 'apparent' install folder (typically something like C:\Program Files\App Name), but will place files & folders elsewhere on the system (e.g. /AppData folder) and write to the registry, etc...
    So, won't all that be lost when creating a Symlink as described above? It doesn't seem to have been addressed, unless again, I missed it?

    And finally, there are also softwares (e.g. Cameyo, Turbo Studio) to create PORTABLE installs...wouldn't that be even easier to do and much easier to manage when in fact reinstalling, moving, etc...?

    I tried both above-mentioned softwares a few years ago without great success but maybe that's changed now or maybe it needs a bit more than just a few clicks to get it to run smoothly, hence...a "how to create a Portable software" thread maybe? :wink:
     
  17. Olymoon

    Olymoon Moderator

    Joined:
    Jan 31, 2012
    Messages:
    5,801
    Likes Received:
    4,465
    Exactly :yes:

    No, nothing is lost when using symlink. That's the opposite, the program get "cheated" and "think" everything is in its original place.

    That's a completely different thing that does not serve the same purpose, and should be the object of a different thread.
     
  18. Pinkman

    Pinkman Audiosexual

    Joined:
    Apr 22, 2016
    Messages:
    2,093
    Likes Received:
    1,944
    A sym(bolic)link points to the NEW location of a folder or file using a Windows shortcut or a macOS alias.

    e.g I move my Omnisphere STEAM folder to my new hard-drive and create a shortcut exactly where it USED to be that points to the new location.

    As @Pagurida said, if you're networked, a Directory Junction is the only way to make things work.
     
  19. Pagurida

    Pagurida Producer

    Joined:
    Nov 30, 2012
    Messages:
    196
    Likes Received:
    149
    Location:
    Brain
    Data in the actual location is not touched by creating a reference to it.
    It is retained even if the referencing link/junction is deleted.
    (Btw, deletion can be carried out with the Del key in Explorer or the RD command in the command line or batch file.)
    However, data that is added, removed, or changed in the linked folder is treated equally in the actual storage location!
    There is no difference for actions like these, whether they are executed in the linked folder or in the real folder.

    Standard installations usually distribute their data necessary for execution to several locations, e.g. C:\Program Files, C:\ProgramData, C:\Users\Username\AppData\Roaming and of course the Windows registry.
    Portable installations have all of them collected inside one folder.
    This makes it easier to transfer and use on portable media such as thumb drives.

    The primary purpose of symbolic links or junction points is to store data in a location other than the one unalterably determined by an application, and at the same time to pretend to the application that the data is in the "correct" location, so that the application is working flawlessly.
     
    Last edited: Mar 1, 2020
  20. DoubleTake

    DoubleTake Audiosexual

    Joined:
    Jul 16, 2017
    Messages:
    2,195
    Likes Received:
    1,151
    Yeah.. After I posted I customized awhile bunch of them. I am not sure if I got them all but it's easy and fast to do if I come across more over time.
     
  21. demberto

    demberto Rock Star

    Joined:
    Nov 27, 2018
    Messages:
    931
    Likes Received:
    325
    Agreed. That's a kernel function used in C/C++ but calling it through rundll makes it callable.
    No you can do it in cmd as well, since all arguments are strings (LPCWSTR or LPCSTR) or DWORD which can be a number as well. So I guess this will work.
     
Loading...
Similar Threads - Symlink different methods Forum Date
r2r waves symlinkinstaller not working in studio one Software Jul 22, 2023
Arturia soundbanks symlink help [SOLVED ] Software Apr 16, 2023
Truepiano 1.9.8 (No Install) (Symlink) Software Nov 20, 2022
need help with symlinks and relocating folders to external drives Mac / Hackintosh May 9, 2022
*SOLVED* Kontakt 6.4.1 (symlink) running with Free Kontakt Player? Kontakt May 13, 2021
Loading...