pehcahn
pehcahn

Reputation: 11

Create script for mklink command

I want to create a bash file (.sh file) that creates a symlink using the dos mklink command.

mklink /D "path" "path"

Use this window command in bash

But when I tried that I got an error: mklink: command not found

How to solve that?

Upvotes: 1

Views: 3651

Answers (1)

Io-oI
Io-oI

Reputation: 2565

For use mklink in you Windows, read the information on ss64.com about.

Elevation

  • By default, only Administrators can create symbolic links. The security setting 'Create symbolic links' can be granted at: Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\*

  • Creating a symbolic link requires elevation, but from Windows 10 build 14972, symlinks can be created without needing to elevate the console as administrator - this does however require that you have Developer Mode enabled.

So, you can enable Developer Mode enabled

enter image description here

enter image description here

enter image description here

I prefer to apply a boot after any changes made to the system settings, this is my habit, so I restarted and typed:

C:\Users\ecker>mklink /D "%userprofile%\Documents\Call of Duty Black Ops II Saves" "C:\Program Files (x86)\Steam\steamapps\common\Call of Duty Black Ops II\players"
symbolic link created for C:\Users\ecker\Documents\Call of Duty Black Ops II Saves <<===>> C:\Program Files (x86)\Steam\steamapps\common\Call of Duty Black Ops II\players
C:\Users\ecker>mklink
Creates a symbolic link.

MKLINK [[/D] | [/H] | [/J]] Link Target

        /D      Creates a directory symbolic link.  Default is a file
                symbolic link.
        /H      Creates a hard link instead of a symbolic link.
        /J      Creates a Directory Junction.
        Link    Specifies the new symbolic link name.
        Target  Specifies the path (relative or absolute) that the new link
                refers to.

Obs.: You can also activate Developer Mode for Windows 10 using PowerShell, also for cmd command line or batch file:

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"

Upvotes: 1

Related Questions