Read Mode
Default

How to Make Shortcut of File or Folder via CMD? | CMD FAQs

February 08, 2017
Make Shortcut of File or Folder via CMD: And, Here we are. Again on the same page of the Book of Life. Today in this article we're going to solve a Query asked by 'Maria Queen' about a Basic, But Quite Important Topic in The Batch Programming. She has asked a Good question bothering Batch programmers from a long time. So, Let's Directly jump into the answer to this amazingly simple, But Important Question.

What is a Shortcut ?

Before Directly diving into the direct answer, we must know few things about it. If you already know about "What is a Shortcut?" You can skip this Section. 
Explanation: A Shortcut file is just a (*.lnk) file - Containing the Path to Target File or Folder. When You'll Double click on such file - You'll be Directed towards that Target file indirectly. So, In a manner You don't need to put the same file / Folder Multiple times in multiple locations in the system. All You need to put shortcuts of that file (Which are quite smaller than the original file / folder). And, Now you can open that file from the desired locations. 
"Ask the right questions, If you're to find the right answers."

Making Shortcuts From CMD!

Although, CMD has a simple and Direct Command for this purpose. But, It requires to Run CMD as Admin - which is quite not possible in every case. We don't know why? But, For making shortcut of any file shouldn't require ADMIN privileges. That's why We are providing two methods as the answer of this question. The first method require Admin, while Second one is quite simple and Doesn't Requires Any additional Resources or Permissions. Let's talk about them Both - One by One.


#1 MKLink Command (Internal Command)

As per the Description of the Command, It creates a Symbolic link to a directory or a file, or create a hard file link or directory junction. Which, simply means - You can create Shortcuts using this Simple command in CMD. But, It requires You to Run CMD as Admin to complete the operation. You need to use the Following Syntax in the Console Screen.

Syntax

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

Where:

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

E.g.: MKlink /D "Holy_Book" "C:\My_Personal"  (Link To A Folder)

#2 Shortcut Plugin [v.1.11] (External Command - ShortCut.exe)

The Plugin is Created By Marty List, in 2000. But, It is being updated periodically! Although, It is a Simple and Easy to use Plugin for creating shortcuts in The windows. You can simply give Commands to it from CMD. Don't forget to Surround Double Quotes ("") around the Path (Text), If it contains Spaces. Otherwise, CMD may give you an error. You can simply use it as the Following Syntax.

Syntax

Shortcut.exe /F:filename /A:C|E|Q [/T:target] [/P:parameters] [/W:workingdir] [/R:runstyle] [/I:icon,index] [/H:hotkey] [/D:description]

Where:

 /F:filename      : Specifies the .LNK shortcut file.
 /A:action          : Defines the action to take (C=Create, E=Edit or Q=Query).
 /T:target           : Defines the target path and file name the shortcut points to.
 /P:parameters   : Defines the command-line parameters to pass to the target.
 /W:working dir : Defines the working directory the target starts with.
 /R:run style      : Defines the window state (1=Normal, 3=Max, 7=Min).
 /I:icon,index    : Defines the icon and optional index (file.exe or file.exe,0).
 /H:hotkey        : Defines the hotkey, a numeric value of the keyboard shortcut.
 /D:description : Defines the description (or comment) for the shortcut.

 Notes:
 - Any argument that contains spaces must be enclosed in "double quotes".
 - If Query is specified (/A:Q), all arguments except /F: are ignored.
 - To find the numeric hotkey value, use Explorer to set a hotkey and then /A:Q
 - To prevent an environment variable from being expanded until the shortcut
   is launched, use the ^ carat escape character like this: ^%WINDIR^%

 Examples:
   /f:"%ALLUSERSPROFILE%\Start Menu\Programs\My App.lnk" /a:q
   /f:"%USERPROFILE%\Desktop\Notepad.lnk" /a:c /t:^%WINDIR^%\Notepad.exe /h:846
   /f:"%USERPROFILE%\Desktop\Notepad.lnk" /a:e /p:C:\Setup.log /r:3

 An argument of /? or -? displays this Help Message and returns 1.
 A successful completion will return 0.
You can Simply Download the Plugin from the Link given at the Bottom of the Article. It is a simple 56 KBs of Batch Plugin. Although, There are other alternatives available using the VBS Language. But, #TheBATeam Prefers to use the pre-existing things in the Universe - in an innovative way, than Creating Everything by your Own. This way, The creators of those things will also get some credit and popularity. And, This mutual exchange of creations and Ideas - leads to awesome creations and Best out of your own Innovation. 

Maybe, The text above makes some sense! But, We would like to know your Feedback and Doubts through comments. We'll be happy to Read them. Thanks For your time! 😏


Keep Sharing, Keep Learning...
Be Happy, Spread Happiness...

Download Link: Shortcut Plugin v.1.11
#TheBATeam

1 comment:

Powered by Blogger.