1

How do I run a cmd.exe command in msys as a superuser? I am the only user on my laptop and have full administrative privileges once I login. I assumed I did when I fired up an msys shell, but running:

cmd //c 'mklink link.txt file.txt'

returns that I do not have sufficient privilege to perform this operation.

  • open a command promopt and esclate the process by using "run as administrator" this only works if the user your using is an Administrator otherwise you have to supply the Administrator's username and password. – Ramhound Jun 3 '14 at 17:24
  • Beautiful. What I did was modify the properties of my msys shortcut to "run as administrator" and that worked perfectly. Thanks for the hint, Ramhound! – greg burgreen Jun 3 '14 at 17:35
  • Administrator rights are not required to create hard links. If that's what you were trying to do, the actual syntax would be cmd /c mklink /h "hard link" "the target file" – and31415 Jun 3 '14 at 17:42
  • Yes, and31415 is correct. I was after symbolic links. Though, my shell required the command to be: cmd //c mklink //h hard_link target_file to escape the forward slash side effects on the msys bash shell. – greg burgreen Jun 3 '14 at 17:45
  • The reason you were getting the not-enough-privileges error is that if you omit the /h switch you're creating a symbolic link, something which was first introduced in Windows Vista along with the mklink command. Per default system settings, you need administrator rights in order to create symbolic links. – and31415 Jun 3 '14 at 17:50
1

Creating hard links

When using the mlink built-in command to create hard links you need to use the /h switch. If you omit it, the command will create a symbolic link instead.

Symbolic links were first introduced in Windows Vista along with the mklink command. Unlike hard links, you do need administrator rights in order to create symbolic links, per default system settings. And that's the very reason you were getting the not-enough-privileges error.

Simply put, this is the command syntax you need to use:

cmd //c mklink //h hard_link target_file

Further reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.