mklink in batch file keep returning insufisent permission

1

I made a code to execute an simbolic link between my Music folder and the music stored in my other hard drive

@ECHO OFF
SET /p bn=Band Name : 
md "%E:\Music\%bn%"
SET /p dl=Album Name :
mklink /d "E:\Music\%bn%\%dl%" "%~1"
pause

The problem is, it keep returning

You do not have sufficient privilege to perform this operation.

when I create a shortcut and check "run as admin" the batch file simply doesn't work.

MrBean56

Posted 2014-07-08T22:16:47.693

Reputation: 11

the wierd thing is that i made a similar code for my movies and it is working :

@ECHO OFF .... SET /p dl=Movie File Name : .... mklink /h "E:\Videos\FR\%dl%" "%~1" .... pause – MrBean56 – 2014-07-08T22:29:13.020

Answers

0

You definitely need to run the batch file as administrator. I think your problem is that you use %~1 which is a reference to the first parameter, isn't it? When you right click the file to run as administrator, you probably aren't assigning additional parameters.

I don't know what your end objective is. If you can add that I can help you get to a solution that works. I have a feeling you are solving a problem with a much harder solution and that there is an easy solution too.

LPChip

Posted 2014-07-08T22:16:47.693

Reputation: 42 190

The %~1 is because I drag and drop the folder to the batch file and the %~1 is calling the location of this folder – MrBean56 – 2014-07-08T23:23:49.463

If there is a totally diffenrent way to do the same thing I am open to suggestion ! – MrBean56 – 2014-07-08T23:49:00.553

My end objective is to be able to see and interact with my C:\user\music folder wich is my ssd, without having anything in it by creating a symlink to my 1TB hdd, wich is E: in this case – MrBean56 – 2014-07-09T05:35:34.823

I already did it manually by runing cmd as admin and entering the location of each everytime, but I figured out that maybe I could do a .bat file to make it easier – MrBean56 – 2014-07-09T05:39:07.670

You can use the command FOR to check on files or folders within a folder and process a command with each folder to it. That means you only run the batch file as administrator and it does everything for you. If you drag/drop a file on the batchfile it is not run as administrator, and thats where your problem lies. – LPChip – 2014-07-09T12:18:25.373

I don't quite get how the FOR command would be in use in my problem. The thing is, I want to be able to pick the folder I downloaded, and as simple as possible, create a symlink and name it in the console. – MrBean56 – 2014-07-09T21:46:51.697

Hmm... Can you do me a favor? Edit your post and write exactly what you want to do with all the steps you do to accomplish it? – LPChip – 2014-07-09T21:51:57.980