Opening Files with Default Application in WSL

Abstract: Resolve file path syntax errors when opening files from WSL by converting Linux paths to Windows format using wslpath and cmd.exe start.

Created: 2026-10-05 by

To open files with their default Windows applications from within the Windows Subsystem for Linux (WSL), use the cmd.exe /c start command followed by the absolute path to the file. Because WSL uses a Linux-style file system, you must first convert your current directory or specific file path to the corresponding Windows drive letter format using wslpath. This method leverages the Windows host's registered file associations, ensuring that documents, images, and code files launch in their native editors without requiring manual configuration inside the Linux environment.

Understanding File Path Translation

The core challenge when interacting with Windows resources from WSL is the difference in path syntax. Linux uses forward slashes (/) and root directories like /home/user, while Windows uses drive letters (e.g., C:) and backslashes (\). The cmd.exe utility running on the Windows host does not understand Linux paths directly. Therefore, any attempt to open a file via Windows commands requires translating the location into a format Windows recognizes. WSL provides a built-in utility called wslpath specifically for this purpose. This tool converts Unix-style paths into Windows-style paths or vice versa. When opening a file, you typically need to convert a Linux path to a Windows path. For example, if you are in the /mnt/c/Users/YourName/Documents directory, wslpath can translate this to C:\Users\YourName\Documents. This translation is the critical bridge that allows seamless integration between the two operating systems.

Basic Command Structure

The standard approach involves chaining the cmd.exe execution with the /c start flag. The /c parameter tells the command processor to carry out the command specified by the following string and then terminate. The start command is the Windows equivalent of "open with default application." It queries the Windows registry for the file association and launches the appropriate program. Here is the general structure:
cmd.exe /c start "" <translated_path>
Note the empty quotes after start. In Windows command line syntax, if the first argument to start contains spaces, it might be interpreted as a window title rather than the file path. Providing an empty string "" explicitly sets the window title to nothing, ensuring the next argument is correctly parsed as the file path. Without this, complex filenames often fail to open. To execute this from your terminal, you combine the conversion and the start command:
cmd.exe /c start "" $(wslpath 'C:/path/to/file.txt')
If you are working with a relative path in your current WSL directory, you can use the variable $PWD which represents the present working directory. You would pass this through wslpath to get the full Windows absolute path.
cmd.exe /c start "" $(wslpath "$PWD/filename.ext")
This one-liner is efficient and works for most common file types including PDFs, Word documents, images, and source code files. It relies entirely on the settings configured in your Windows OS, meaning if you have changed the default app for .jpg files in Windows Explorer, WSL will respect that change automatically.

Handling Spaces in Filenames

A common pitfall occurs when file names contain spaces. Even with the empty quotes trick, it is safer to ensure the path is properly quoted during the translation process. You can wrap the output of wslpath in double quotes within the shell command.
cmd.exe /c start "" "$(wslpath "$PWD/my file.docx")"
This ensures that the Windows start command receives a single, unbroken string representing the file location, preventing errors where Windows tries to open my instead of my file.docx.

Opening Directories and Explorers

Sometimes you do not want to open a specific file but rather browse a folder. You can achieve this by pointing the start command at a directory path. When you provide a directory path to cmd.exe /c start, Windows opens the File Explorer window at that location.
cmd.exe /c start "" $(wslpath "$PWD")
This is particularly useful when you are deep in a project structure in WSL and need to see the files in the Windows GUI context. It effectively mirrors the behavior of right-clicking a folder and selecting "Open in Explorer." If you want to open a specific subdirectory, simply append the folder name to the path before translation. For more advanced navigation, you might prefer to launch the Windows Terminal or a specific explorer instance. However, for simple browsing, the start command is sufficient. It maintains consistency with how files are opened, treating folders as navigable entities within the default file manager.

Creating Convenient Aliases

Typing the full cmd.exe /c start ... sequence repeatedly can be tedious. To streamline your workflow, you can create aliases in your WSL shell configuration file, typically ~/.bashrc or ~/.zshrc. By defining a short function or alias, you can open files with a single keyword. Add the following to your configuration file:
alias wo='cmd.exe /c start "" $(wslpath "$PWD/$1")'
After reloading your shell with source ~/.bashrc, you can use wo filename.pdf to open that file. This alias takes the first argument provided to it, combines it with the current working directory, translates it, and launches it. This significantly reduces friction when switching between coding in the terminal and reviewing outputs in Windows applications. If you frequently work across different drives, you may also want an alias that handles absolute paths directly without needing $PWD. A more robust function could check if the argument starts with a slash or drive letter. However, for daily development tasks, the basic alias covers 90% of use cases.

Troubleshooting Common Issues

While this method is generally reliable, several issues can arise depending on your WSL version and Windows configuration. One frequent error is "The system cannot find the file specified." This usually happens when the path translation fails because the file does not exist in the mounted Linux filesystem, or the path contains characters that wslpath cannot handle. Always verify the file exists in WSL before attempting to open it using ls. Another issue is that the file opens but in a blank window. This often indicates that the default application associated with the file type in Windows is misconfigured. Check your Windows Settings > Apps > Default Apps to ensure the correct program is assigned to the file extension. Additionally, some older versions of WSL had bugs with wslpath returning incorrect paths for symlinks. Ensuring you are running the latest version of WSL via wsl --update in PowerShell can resolve these edge cases. If you encounter permission errors, remember that WSL runs as a user mapped to your Windows account. Generally, permissions are inherited, but if you are trying to open a file owned by root or another user, you may need to adjust permissions in Windows Explorer or use sudo in WSL if necessary. For most personal files, this is not a concern. For users managing large datasets or external drives, understanding how WSL mounts these volumes is helpful. As discussed in related guides about transferring installations or mounting folders, the way drives are attached affects path availability. If a drive is not mounted correctly, wslpath will fail because the Linux path does not exist. Ensure your Windows drives are accessible via /mnt/ before attempting to open files from them. Finally, consider security implications. Opening files from WSL executes commands on the Windows host. While start is safe, be cautious with arbitrary strings passed to cmd.exe. Never pass user input directly into a cmd.exe command without validation, as this could lead to command injection vulnerabilities. Stick to using wslpath on known file paths to maintain a secure boundary between the two environments.

Frequently Asked Questions

Can I open a file directly without converting the path?

No, Windows commands like start do not understand Linux paths such as /home/user. You must use wslpath to translate the path to a Windows format like C:\Users\user before passing it to the command. Attempting to use a Linux path directly will result in a "file not found" error.

Why does my file open in a new window instead of the existing application?

The start command typically launches a new instance of the application unless the application supports Single Instance Mode. Most modern editors like VS Code or browsers support this, so they will switch to the existing window. Older applications may always open a new window regardless of the command used.

How do I open a file in a specific editor instead of the default one?

You can bypass the default association by specifying the executable directly. For example, use code $(wslpath "$PWD/file.txt") to open a file in Visual Studio Code. This requires the editor to be installed and accessible in your Windows PATH. This method gives you explicit control over which application handles the file.

Does this work for network drives or UNC paths?

Yes, wslpath can handle UNC paths if they are properly mounted in WSL. If you have a network share mounted at /mnt/share, you can convert it to \\server\share and open it. However, performance may vary depending on the network latency and the stability of the mount point.

What should I do if wslpath returns an empty string?

An empty string usually means the input path is invalid or the file does not exist in the WSL filesystem. Check your current directory with pwd and verify the file name. Also, ensure you are using the correct syntax for wslpath, especially regarding quotes around paths containing spaces.

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