How to Fix the 'Invalid Switch' Error When Using mklink in Windows 10

Abstract: Fix the Invalid Switch error in mklink by adding required flags like /D or /J and quoting paths with spaces.

Created: 2026-09-10 by
The 'Invalid Switch' error with mklink in Windows 10 usually stems from incorrect syntax, such as missing the required link type flag like /D for directories or /J for junctions. This issue often occurs when users attempt to create symbolic links without specifying whether they are linking a file or a folder, leading the command interpreter to reject the arguments provided. Resolving this requires verifying the exact structure of your command line and ensuring that both the source and destination paths are correctly formatted. Below is a comprehensive guide to troubleshooting and fixing this common command-line error.

Understanding the Syntax Requirements

The mklink command is a powerful tool for creating symbolic links, but it is strict about its arguments. The general syntax is:
mklink [[/D] | [/H] | [/J]] <Link> <Target>
If you omit the switch (/D, /H, or /J), Windows assumes you might be trying to use an invalid parameter. For example, running mklink C:\Link C:\Target will fail because the system does not know if C:\Link is a file or directory link. You must explicitly state the type of link you wish to create.

Common Causes of the Error

Several specific scenarios trigger the 'Invalid Switch' message. Identifying which one applies to your situation is crucial for a quick fix.
  • Missing Link Type: As mentioned, failing to include /D (for directories) or /J (for junctions) is the most frequent cause.
  • Incorrect Order of Arguments: The target path must always follow the link path. Swapping them can confuse the parser.
  • Special Characters in Paths: If your folder names contain spaces or special characters, they must be enclosed in double quotes. Unquoted paths with spaces are often misinterpreted as separate switches.
  • Running Without Admin Privileges: Creating certain types of symbolic links, especially those pointing outside the user profile or involving system directories, requires elevated privileges. While this often results in an "Access Denied" error, improper permission handling can sometimes manifest as syntax errors depending on the context.

Step-by-Step Fix

Follow these steps to correct your command and successfully create the link.
  1. Open Command Prompt as Administrator: Press Win + X and select "Windows PowerShell (Admin)" or "Command Prompt (Admin)". This ensures you have the necessary permissions.
  2. Verify Your Paths: Ensure that both the source (target) and destination (link) paths exist and are spelled correctly. Use dir to check if the folders are present.
  3. Apply Correct Syntax:
    • For a directory symbolic link: mklink /D "C:\Path\To\Link" "C:\Path\To\Target"
    • For a hard link (files only): mklink /H "C:\Path\To\Link" "C:\Path\To\Target"
    • For a directory junction: mklink /J "C:\Path\To\Link" "C:\Path\To\Target"
  4. Handle Spaces in Names: Always wrap paths containing spaces in double quotes. For instance, mklink /D "My Folder" "Another Folder" works, but mklink /D My Folder Another Folder fails.

Troubleshooting Persistent Issues

If you have followed the syntax correctly and still encounter errors, consider the following advanced checks. First, ensure that the drive letter or UNC path is valid. Sometimes, network drives or disconnected volumes can cause unexpected parsing issues. Additionally, check for hidden characters in your batch scripts or copy-pasted commands, which can introduce invisible switches that break the command. For more complex storage issues, you might find related guidance useful. See Troubleshooting Windows: How to Fix Hard Drive Issues Using Command Line for broader diagnostic techniques. Also, if you are dealing with metadata-related queries during link creation, How to Get File Description Field from File Metadata Using Command Line may provide additional context on file properties.

Best Practices for Symbolic Links

Once your link is created, it is good practice to verify its existence using dir. A successful symbolic link will appear in directory listings with a special indicator. Remember that symbolic links are sensitive to changes in the target location. If you move the target folder, the link will break. To avoid this, use absolute paths rather than relative ones whenever possible. Furthermore, be cautious when deleting symbolic links. Deleting the link itself does not delete the target data, but deleting the target while the link exists will leave the link dangling. Always backup important data before manipulating system directories with mklink.

Frequently Asked Questions

Why do I get 'Invalid Switch' even with /D?

This typically happens if there are extra spaces or unquoted paths between the switch and the arguments. Ensure your command follows the exact format: mklink /D "Link" "Target". Any deviation, such as mklink /D Link Target where either contains spaces, will cause the parser to fail.

Can I create a symbolic link to a network drive?

Yes, you can create symbolic links to network drives using UNC paths (e.g., \\Server\Share). However, you must use the /D switch for directories. Note that some applications may not handle network-based symbolic links well due to latency or permission constraints.

What is the difference between mklink /D and /J?

/D creates a standard symbolic link that can span different volumes and work with files and directories. /J creates a directory junction, which is limited to local volumes and is generally less flexible. Junctions are older technology and should be used only for compatibility with legacy software that expects junction behavior.

How do I remove a symbolic link?

You cannot use del or rd directly on a symbolic link if it points to a directory, as it might delete the contents. Instead, use rmdir (or rd) on the link itself. For example, rmdir C:\Path\To\Link will remove only the link, leaving the target intact.

Does mklink work in Windows 10 Home edition?

Yes, mklink is available in all editions of Windows 10, including Home. The functionality is identical across versions, provided you have administrative privileges to create links in protected directories.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More