Create symbolic link (MKLINK /D)

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

franz1960
Junior Member
Junior Member
Posts: 3
Joined: 2016-06-26, 07:56 UTC
Location: Germany

Create symbolic link (MKLINK /D)

Post 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
User avatar
Dalai
Power Member
Power Member
Posts: 9387
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post 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
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
franz1960
Junior Member
Junior Member
Posts: 3
Joined: 2016-06-26, 07:56 UTC
Location: Germany

Post 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
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post 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.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6481
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post 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.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

These commands aren't useful when you need to create links for many files...
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6481
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post 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
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post 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).
franz1960
Junior Member
Junior Member
Posts: 3
Joined: 2016-06-26, 07:56 UTC
Location: Germany

Post 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.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post 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).
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6481
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post 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.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Horst.Epp,
Ah, I see the asterisk now. :)
Speeder
Junior Member
Junior Member
Posts: 3
Joined: 2023-09-23, 10:01 UTC

Re: Create symbolic link (MKLINK /D)

Post 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.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6481
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Create symbolic link (MKLINK /D)

Post 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.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3447)
TC 11.03 x64 / x86
Everything 1.5.0.1372a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73
QAP 11.6.3.2 x64
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Create symbolic link (MKLINK /D)

Post by *MVV »

Also these user-commands don't support Unicode names.
Post Reply