Page 1 of 2

Create symbolic link (MKLINK /D)

Posted: 2016-06-26, 08:13 UTC
by franz1960
In V8.52a one can create a shortcut by dragging with the right mouse button. A context menu item "Create Shortcut" appears. It would be great to have an additional menu item "Create Symbolic Link" which creates a symbolic link equal to the "MKLINK /D" windows command.

Such symbolic links are useful e.g. to include existing folders in the OneDrive folder.

Cheers,
Franz

Posted: 2016-06-26, 12:34 UTC
by Dalai
While there are requests to add native support for Symlinks/Junctions/Hardlinks to TC, you can use NTLinksMaker or NTFS Links which you can add to TC's button bar or starter menu.

Regards
Dalai

Posted: 2016-06-26, 14:03 UTC
by franz1960
I'm aware of the plugins, but it seems to me more natural and intuitive to find this function where one would expect it. And as it doesn't seem to be complicated and error-prone to implement, I still propose to include it into the right mouse button drag menu.

Regards,
Franz

Posted: 2016-06-26, 18:29 UTC
by MVV
Long-time TC users won't expect any features in drag menu because this menu is a Windows Explorer feature, and I believe that there is an Explorer extension that do what you want.

With TC, it is much more native to create links via copy/move/create shortcut/some other similar dialogs, and that is what mentioned tools do - you only need to assign a shortcut for them. E.g.: F5/F6 - copy, Ctrl+Shift+F5 - create shortcuts, Alt+F6 - create symlinks/junctions (via one of mentioned tools).

It is not bad to use plugins, it is bad to integrate into TC itself things that may be easilly integrated into TC via plugins.

Posted: 2016-06-26, 18:59 UTC
by Horst.Epp
You dont even need plugins.
If you have a look on Petermad's Extended English Menus
http://totalcmd.net/authors/1223914.html
you will find em_commands which can be added as buttons or Main menu entries:

Code: Select all

[em_ext_symlinkd]
cmd=*%COMSPEC% /K
param=if exist %P%N\* (mklink /D %T%N %P%N) else (echo The cursor must be on a FOLDER)
path=%SYSTEMDRIVE%\
menu=Make Symlink in Opposite Panel to FOLDER Under Cursor
button=%COMMANDER_EXE%,12

[em_ext_symlink]
cmd=*%COMSPEC% /K
param=if not exist %P%N\* (mklink %T%N %P%N) else (echo The cursor must be on a FILE)
path=%SYSTEMDRIVE%\
menu=Make Symlink in Opposite Panel to FILE Under Cursor
button=%COMMANDER_EXE%,12

[em_ext_hardlink]
cmd=%COMSPEC% /K
param=if not exist %P%N\* (mklink /H %T%N %P%N) else (echo The cursor must be on a FILE)
path=%SYSTEMDRIVE%\
menu=Make Hardlink in Opposite Panel to FILE Under Cursor (Only on Same Drive)
button=%COMMANDER_EXE%,12
His packages are also contain all TC commands in Menus and lot of specific buttons.

Posted: 2016-06-26, 19:38 UTC
by MVV
These commands aren't useful when you need to create links for many files...

Posted: 2016-06-27, 06:53 UTC
by Horst.Epp
MVV wrote:These commands aren't useful when you need to create links for many files...
Thats right but I mostly need it for single directories.
For complex cases I have Link Shell Extension (LSE)
http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html

Posted: 2016-06-27, 07:21 UTC
by MVV
Horst.Epp wrote:For complex cases I have Link Shell Extension (LSE)
http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html
Mentioned by me above. :)
Since I don't work in Explorer at all, it is much faster and convenient for me to use NTLinks Maker (it was made as NTFS Links analog to fulfil my needs).

Posted: 2016-06-27, 09:00 UTC
by franz1960
@Horst.Epp: Thank you! Problem solved: I added a new item in the button bar using the em_ext_symlinkd settings. Works like a charm.

Posted: 2016-06-27, 09:15 UTC
by MVV
Since it works for you, it seems that you're always running TC as administrator, which is not a safe way of using it. It is more safe to use non-elevated TC and elevate only operations that require it (like symlink creation or writing to system folders).

Posted: 2016-06-27, 09:31 UTC
by Horst.Epp
MVV wrote:Since it works for you, it seems that you're always running TC as administrator, which is not a safe way of using it. It is more safe to use non-elevated TC and elevate only operations that require it (like symlink creation or writing to system folders).
You don't need running TC as Administrator for that em_command to work.
There comes an UAC prompt if enhanced rights are required.

Posted: 2016-06-27, 09:52 UTC
by MVV
Horst.Epp,
Ah, I see the asterisk now. :)

Re: Create symbolic link (MKLINK /D)

Posted: 2023-09-23, 10:05 UTC
by Speeder
I see that this is a pretty old post, but just in case anyone finds this, and wants a better solution, add this to the usercmd.ini file:

Code: Select all

[em_ext_junction]
cmd=*%COMSPEC% /C
param=@for /f "usebackq tokens=*" %%i in ("%F") do @( if exist "%P%%~i\" ( mklink /J "%T%%~i" "%P%%~i" ) else ( mklink "%T%%~i" "%P%%~i" ) )
menu=Make directory junction or file symlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1

[em_ext_symlink]
cmd=*%COMSPEC% /C
param=@for /f "usebackq tokens=*" %%i in ("%F") do @( if exist "%P%%~i\" ( mklink /D "%T%%~i" "%P%%~i" ) else ( mklink "%T%%~i" "%P%%~i" ) )
menu=Make directory or file symlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1

[em_ext_junction_hard]
cmd=*%COMSPEC% /C
param=@for /f "usebackq tokens=*" %%i in ("%F") do @( if exist "%P%%~i\" ( mklink /J "%T%%~i" "%P%%~i" ) else ( mklink /H "%T%%~i" "%P%%~i" ) )
menu=Make directory junction or file hardlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1

[em_ext_symlink_hard]
cmd=*%COMSPEC% /C
param=@for /f "usebackq tokens=*" %%i in ("%F") do @( if exist "%P%%~i\" ( mklink /D "%T%%~i" "%P%%~i" ) else ( mklink /H "%T%%~i" "%P%%~i" ) )
menu=Make directory symlink or file hardlink in the opposite panel for selected files
button=%COMMANDER_PATH%\WCMICON2.DLL,65
iconic=1
After that, I would suggest adding a new entry to the start menu, and assigning the Ctrl+Alt+F5 hotkey to the preferred version of the action.

Re: Create symbolic link (MKLINK /D)

Posted: 2023-09-23, 11:33 UTC
by Horst.Epp
Speeder wrote: 2023-09-23, 10:05 UTC I see that this is a pretty old post, but just in case anyone finds this, and wants a better solution, add this to the usercmd.ini file:
...
After that, I would suggest adding a new entry to the start menu, and assigning the Ctrl+Alt+F5 hotkey to the preferred version of the action.
Using the NTLinksMaker add-on makes this much simpler,
as it only needs one button for all options.

Re: Create symbolic link (MKLINK /D)

Posted: 2023-09-26, 09:58 UTC
by MVV
Also these user-commands don't support Unicode names.