Open file console windows

Все способы:

  • Шаг 1: Запуск «Командной строки»
  • Шаг 2: Переход в папку файла
  • Шаг 3: Запуск файла в консоли
  • Дополнительная информация
    • Как запустить файл без перехода по адресу
    • Выбор нужной программы для запуска
    • Запуск программ в PATH
  • Вопросы и ответы: 0

Шаг 1: Запуск «Командной строки»

При запуске консоли следует отметить несколько важных нюансов. Если осуществляется запуск, например, инсталляционного файла для установки программы на компьютер требует расширенных прав пользователя, то открывать «Командную строку» требуется от имени администратора.

Помимо «Командной строки», можно использовать и другие консоли: «Windows PowerShell» или «Терминал» (обновленную консоль в Windows 11).

Чтобы открыть «Командную строку», можно воспользоваться строкой системного поиска. Введите запрос cmd, затем выберите нужный тип запуска — строку «Запуск от имени администратора».

как открыть файл через командную строку-01

Обо всех способах запуска в разных версиях операционной системы Windows мы писали ранее в отдельных пошаговых материалах.

Подробнее: Как открыть «Командную строку» в Windows 11 / Windows 10 / Windows 7 / BIOS

Читайте также: Устранение проблем с запуском «Командной строки»

Шаг 2: Переход в папку файла

Теперь через «Командную строку» нужно попасть в папку, где располагается файл, который нужно запустить. Принцип такой же, как с «Проводником»: сначала открывается каталог, после чего открывается файл в нем.

  1. Если есть доступ к штатному файловому менеджеру (либо стороннему), проще скопировать адрес оттуда. Для этого перейдите к нему через программу, затем выделите путь в адресной строке и скопируйте его в буфер обмена (можно использовать контекстное меню, вызванное правой кнопкой мыши, либо сочетание клавиш «Ctrl + C»).
  2. как открыть файл через командную строку-02

  3. Перейдите к окну консоли, введите команду cd и вставьте в него скопированный адрес, используя сочетание клавиш «Ctrl + V». После нажмите на клавишу «Enter», чтобы выполнить запрос.

    Обратите внимание, что «Командная строка» может некорректно воспринимать путь, где в названиях папок есть пробелы. В этом случае предварительно заключите всю строку в двойные кавычки ().

    В нашем случае команда выглядит так: cd C:\Users\Mara Bu\Pictures\Lumpics

  4. как открыть файл через командную строку-03

  5. Если доступа к «Проводнику» нет, можно перейти в нужную директорию без него, напрямую через «Командную строку». Для этого потребуется выполнить несколько команд cd, по очереди открывая каждую папку в пути. Например, если искомый файл располагается на системном диске в пользовательской папке с изображениями, сначала выполните команду cd C:\Users.
  6. как открыть файл через командную строку-04

  7. Следом введите запрос с именем этой пользовательской папки: cd User_Name.
  8. как открыть файл через командную строку-05

  9. Теперь откройте сам каталог с изображениями, выполнив cd Pictures.
  10. как открыть файл через командную строку-06

Для отображения содержимого папок можно дополнительно использовать команду dir. Это поможет лучше сориентироваться в хранилище через «Командную строку».

Шаг 3: Запуск файла в консоли

После того, как путь к файлу указан, можно переходить к его непосредственному запуску:

  1. Чтобы запустить файл, введите команду start File_Name, введя имя файла и его расширение через точку. После нажмите на клавишу «Enter».

    Читайте также: Включение отображения расширений файлов в Windows 11 / Windows 10 / Windows 7

  2. как открыть файл через командную строку-07

  3. Вместо команды start можно использовать точку и слэш, тогда запрос будет примерно таким: .\File_Name.txt (имя файла и расширение проставьте свои).
  4. как открыть файл через командную строку-08

Атрибут .\ — это указание на поиск файла в текущей директории. Можно прописать только название файла и расширение, затем нажать на клавишу «Tab» вместо «Enter», после чего консоль самостоятельно введет запрос для запуска файла.

Дополнительная информация

Есть дополнительные сведения, касающиеся запуска файлов и программ через консоль «Командная строка». Их стоит упомянуть, поскольку они могут оказаться полезными в различных ситуациях.

Как запустить файл без перехода по адресу

Существует способ запуска файла без перехода по полному адресу, где он располагается на хранилище компьютера. По сути, Шаги 2 и 3 в таком случае можно пропустить, и после открытия консоли сразу выполнить команду, где подразумевается просто полный адрес и название файла с расширением. Например, C:\Users\User_Name\Desktop\Lumpics\lumpics.txt. После выполнения команды такого типа (причем не обязательно использовать конструкции cd или .\) консоль должна запустить указанный файл.

как открыть файл через командную строку-09

У метода есть несколько недостатков, поэтому мы отдельно вынесли этот вариант. Например, при использовании запроса можно легко запутаться с адресом и указать неправильный путь, если приходится вручную прописывать команду. Кроме того, в «Командной строке» не сохранится путь к текущей директории, в отличие от способа, рассмотренного в инструкции выше, и, если нужно запустить несколько файлов из папки, потребуется каждый раз вводить полный путь.

Выбор нужной программы для запуска

Важно знать, что запуск файлов через консоль осуществляется только через те программы, которые уже под них ассоциированы. То есть, если это текстовый документ в формате TXT, он может открываться в Notepad++, но что, если требуется открыть его в другом редакторе, например, в штатном «Блокноте»? Для этого предварительно нужно запустить приложение через «Командную строку», указав полный путь, а потом через пробел выполнить запуск файла с расширением (или адресом, в соответствии с одной из рекомендаций выше).

Запрос может выглядеть так, как один из представленных вариантов ниже:

  • notepad lumpics.txt
  • C:\Windows\System32\notepad.exe C:\Users\User_Name\Desktop\Lumpics\lumpics.txt
  • как открыть файл через командную строку-10

Обратите внимание, что первая команда сработает лишь в том случае, если путь до исполняемого файла программы прописан в переменной PATH, а сам файл находится в директории, в которую ранее был осуществлен переход через консоль. Вторая команда подразумевает написание полных путей к исполняемому файлу приложения и файла, который будет открываться через это приложение.

Запуск программ в PATH

Еще стоит рассказать про запуск программ в переменной окружения PATH, о чем мы выше упоминали. Это касается системного программного обеспечения и утилит, которые прописывают свои пути к этой переменной. Их можно запускать без указания директории и расширения (EXE). К таким программам относятся:

  • «Проводник»explorer;
  • «Блокнот»notepad;
  • «Диспетчер задач»taskmgr;
  • «Командная строка»cmd.

Если интересна тема переменных среды в Windows, рекомендуем ознакомиться с нашим руководством на сайте.

Подробнее: Изучаем переменные среды в Windows 10 и 11

Наша группа в TelegramПолезные советы и помощь

Microsoft keeps adding new features as they introduce new versions of Windows, and one cool thing they’ve added is the Windows Terminal. This guide will talk about how you can open files and folders with Windows Terminal’s Command Prompt (CMD) or PowerShell on Windows 11.

Also see: How to Download an FTP File Using CMD in Windows 11/10

How to Open a File or Folder in Windows 11 Terminal CMD

What is Windows Terminal?

Windows Terminal is the new app from Microsoft that lets you use different command-line tools like Command Prompt (CMD), PowerShell, and Azure Cloud Shell all in one place. It usually starts up with PowerShell, which is great for managing your system because it can do more stuff than CMD. But if you’re more into CMD or need it for certain things, you can change your Windows Terminal to start with CMD instead.

Changing the default terminal to CMD in Windows Terminal

If you want to make CMD your go-to in Windows Terminal, here’s how:

  1. Open Windows Terminal by right-clicking the Start menu and choosing “Windows Terminal (Admin)“.
    Open Windows Terminal Admin in Windows 11

  2. Hit the down arrow at the top, near the tabs.
  3. Pick “Settings” from the menu that pops up.
  4. On the left, click “Startup“.
  5. Then, use the dropdown next to “Default profile” to select “Command Prompt“.
    Change Windows Terminal default to CMD

  6. Hit “Save” and restart Windows Terminal to see the change.

Related resource: Add Folder to Path Environment Variable in Windows 11/10

Opening a file in Windows Terminal

Want to open a file with Windows Terminal? Just go to where the file is and tell CMD or PowerShell to open it.

Read: How to Change Directory/Drive in CMD on Windows 11

In Command Prompt:

  1. Start Windows Terminal in CMD mode.
  2. Use the cd command and the path to get to where your file is. Like, cd C:\Documents for a file in C:\Documents.
  3. Then, to open the file, type start followed by the file’s name, like start example.txt.

Open file in Windows Terminal CMD

In PowerShell:

  1. Start Windows Terminal in PowerShell mode.
  2. Like in CMD, use cd to get to your file’s place.
  3. To open it, type Invoke-Item or ii, then the file’s name, like Invoke-Item example.txt or ii example.txt.

Open files Windows Terminal PowerShell command

Useful tip: What is “Copy as Path” in Windows 11 and what does it do?

Opening a folder via Windows Terminal

To open a folder with Windows Terminal, you’ll use a different command in CMD or PowerShell.

In CMD:

  1. Fire up Windows Terminal in CMD mode.
  2. Go to your folder with the cd command, like cd C:\Documents.
  3. Then, open the folder by typing start ..

Open a folder in Windows Terminal CMD

In PowerShell:

  1. Open Windows Terminal in PowerShell mode.
  2. Get to your folder the same way as in CMD.
  3. Open it by typing ii ..

Open a folder in File Explorer using command in Windows Terminal

These steps will get File Explorer up and show you the folder, making it easy to look at and manage your files with a nice graphical view, especially when you want to see everything at once while still using the terminal.

Recommended guide: How to Take Ownership of a File, Folder or Drive in Windows 11

Some additional tips

You can even drag and drop a file or folder into the Windows Terminal window to quickly fill in its path. This trick saves a lot of time, especially if you’re working with files or folders buried deep in your computer.

Windows Terminal also has a search feature. Press Ctrl+Shift+F, and you can search for anything in your terminal session. This is super handy when you’re trying to find something specific in a bunch of text.

If there’s a folder you use a lot, you can make Windows Terminal start there by changing the startingDirectory in your settings. This way, you’re always where you need to be when you open the terminal.

And if you ever get stuck on a command, both CMD and PowerShell can help. Just type help followed by the command you’re curious about, and you’ll get all the info you need.

Windows Terminal Help Command

A quick recap

Even though we love clicking and seeing things in graphical interfaces, sometimes they’re not the fastest way to get things done. Command-line interfaces, or CLI for short, are great for quick tasks, automating repetitive stuff, managing files, and more. They’re essential for system admins and anyone who wants to control their computer more directly.

Knowing how to use the command line to open files and folders is a really useful skill. And with Windows Terminal letting you choose between PowerShell and CMD, you can pick the best tool for what you need to do.

  • Home
  • News
  • How to Open a File/Folder in Command Prompt (CMD) Windows 10

By Alisa |
Last Updated

Wonder how to open a file cmd or how to open a folder in Command Prompt on Windows 10? This tutorial provides a step-by-step guide. Also, if you can’t find some files or folders in Windows 10, or some files are unexpectedly lost in your Windows 10 computer, MiniTool free data recovery software for Windows 10/8/7 can help you easily recover lost files.

You can also open files from Command Prompt. Wonder how to open a file or folder in Command Prompt on Windows 10? Check the step-by-step guide in this tutorial.

How to Open a File CMD Windows 10 in 2 Steps

Step 1 – Open Command Prompt

You have several ways to open Command Prompt in Windows 10.

You can press Windows + R keys on the keyboard to open Windows Run dialog. Then type cmd in the Run box. If you want to run Command Prompt as Administrator, you need to press Ctrl + Shift + Enter keys at the same time.

Alternatively, you can also click Start or Search box in Windows 10, and type cmd or command prompt. Right-click the Command Prompt app in the list and choose Run as administrator.

Step 2 – Open Files from Command Prompt

Normally you have two ways to open a file using cmd. One is to move the folder that the file is in, the other is to open the files directly in Command Prompt.

Method 1. How to open a file with cmd by moving to the folder firstly

  • You can use the cd command to move to the exact folder the file lies in. For instance, cd C:\Users\mini\Desktop.
  • After you are in the correct folder path, you can type the name of the file with its extension, e.g. “travel.png”, and hit Enter button to open it.

how to open a file cmd

Method 2. How to open a file using cmd directly

You can also choose to open files from Command Prompt on Windows 10 directly, instead of going to the folder path. You can input the full path, file name and its file extension to open the target file, e.g. “C:\Users\mini\Desktop\travel.png”.

open files from Command Prompt

You can also freely specify an app to open the file. You need to type the whole path of the app ahead of the path of the file, for example, “%windir%\system32\mspaint.exe” “C:\Users\mini\Desktop\travel.png”. Press Enter to open the file using CMD.

specify an app to open a file in Command Prompt

How to Open a Folder in Command Prompt Windows 10

You can also open a folder from Command Prompt with the command line below.

After you enter into Command Prompt window by following the operation above, you can open a folder in File Explorer in Command Prompt. The command line can be like this, start %windir%\explorer.exe “C:\Users\mini\Desktop”.

how to open a folder in Command Prompt

Tip: Need to mention that you need to enclose the path of a file or folder in double quotation marks, since some folder or files names have spaces in them.

>> Quick Video Guide:

To Recover Unexpectedly Lost Files or Folders in Windows 10

Sometimes you may suffer unexpected data loss in Windows 10 due to various reasons, e.g. system crash, Blue Screen error (e.g. Bad Pool Caller BSOD error), power outage, malware/virus infection, hard drive failure, etc. To easily recover lost data for free, you can choose the best free data recovery software to realize it.

MiniTool Power Data Recovery, a 100% clean and free data recovery software for Windows 10/8/7, enables you to easily recover mistakenly deleted files or lost files from computer local drive, external hard drive, SSD drive, USB drive (pen drive data recovery), SD card, and more.

MiniTool Power Data Recovery TrialClick to Download100%Clean & Safe

About The Author

Position: Columnist

Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.

To open a file using the Command Prompt (cmd), you can use the `start` command followed by the filename, as shown in the example below:

start filename.txt

Understanding CMD and Its Usefulness

What is CMD?

The Command Prompt, or CMD, is a command-line interpreter in Windows systems that allows users to execute commands and perform various operations. It provides a straightforward interface for managing files, executing scripts, and interacting with the system without the need for a graphical user interface. CMD can be particularly powerful for troubleshooting, system administration, and automating repetitive tasks.

Benefits of Using CMD

Using CMD comes with several distinctive advantages:

  • Speed and Efficiency: CMD allows you to execute commands quickly without navigating through multiple graphical menus. This can dramatically increase productivity, especially for experienced users.

  • Automation and Scripting: With CMD, you can create batch files and scripts to automate a series of commands, saving significant time and effort on routine tasks.

Command for Open File in Cmd: A Quick Guide

Command for Open File in Cmd: A Quick Guide

Basic Concepts of File Navigation in CMD

How to Navigate to a File’s Directory

Before opening a file, you must navigate to its directory using the `cd` command. This command stands for «change directory» and allows you to move through the file system.

To change to the directory where your file is located, use:

cd C:\path\to\your\file

For example, if your file is in `C:\Documents`, you would type:

cd C:\Documents

Listing Files in a Directory

Once you’re in the desired directory, you can see the files available there by using the `dir` command. This command lists the contents of the current directory, providing a quick overview of available files and folders.

You would simply type:

dir

How to Open a File on Cmd: A Quick Guide

How to Open a File on Cmd: A Quick Guide

How to Open a File From CMD

The Command to Open a File in CMD

After navigating to the correct directory, the command to open a file in CMD prompt is straightforward. The syntax to open a file is as follows:

start <filename>

This command instructs Windows to initiate the associated program and open the specified file.

How to Open Files Using CMD

Opening Text Files

To open a `.txt` file using CMD, simply use:

start example.txt

This command will open the file in the default text editor, which is typically Notepad.

Opening Word Documents

If you want to open a Word document, you can do that with:

start document.docx

Make sure you have Microsoft Word installed on your system since it is the default program for `.docx` files.

Opening Other File Types

CMD can open a variety of file types. Here are a few examples:
To open an image file:

start image.png

Similarly, to open a PDF file, you can type:

start document.pdf

Always ensure you have the appropriate software to handle these file types installed on your system.

How to Open a Folder in Cmd: A Simple Guide

How to Open a Folder in Cmd: A Simple Guide

Advanced Techniques for Opening Files with CMD

Specifying Full Paths for Files

Sometimes, it’s necessary to specify the full path to a file, especially if you are not currently in the file’s directory. The full path ensures that CMD can locate the file without needing to navigate first.

For instance:

start C:\path\to\your\file\example.txt

This command will open the specified file regardless of your current directory.

Opening Files with Specific Applications

You can also specify which application should be used to open a file. This is useful when you want to open a file with a program different from its default association.

For example, if you want to use Notepad to open a text file, the command would look like this:

start /B notepad example.txt

The `/B` switch ensures that the command remains in the same session, rather than opening an additional command prompt window.

Mastering Commands for Cmd Prompt: A Quick Guide

Mastering Commands for Cmd Prompt: A Quick Guide

Troubleshooting Common Issues

Common Errors When Opening Files

There are a few common errors users may encounter when executing the command to open a file in CMD prompt:

  • File Not Found: This error occurs when the specified file or path does not exist. To troubleshoot, verify the file name (including its extension) and ensure you are in the correct directory.

  • Application Not Associated with the File Type: If CMD cannot find an appropriate program to open the file, you’ll need to check your file associations in Windows settings or specify the application with the command as mentioned earlier.

Checking File Associations

To check and manipulate how files are associated with applications, you can use the `assoc` and `ftype` commands. These commands allow you to verify which application is set to open a specific file type and change it if necessary.

assoc .txt
ftype txtfile

Create File in Cmd: A Quick Guide to Getting Started

Create File in Cmd: A Quick Guide to Getting Started

Conclusion

Mastering the command to open a file in CMD prompt can significantly enhance your efficiency in managing files and executing tasks via the command line. With practice, you’ll find that CMD offers a simple yet powerful alternative to traditional graphical interfaces for file management.

Read a File in Cmd: Quick and Easy Steps

Read a File in Cmd: Quick and Easy Steps

Additional Resources

For further reading on CMD commands and their functionalities, consider exploring some well-regarded online resources, forums, and communities where fellow CMD enthusiasts gather to share tips and insights. This will not only expand your knowledge but also provide you with support as you explore the vast potential of the command prompt.

≡ Menu

Windows Commands, Batch files, Command prompt and PowerShell

on July 16, 2009

by Srini

On  a Windows machine, we can open a text file from command prompt by just giving the file name.
For example to open a text file named file1.txt, we just need to type file1.txt in the command prompt and press ‘Enter’. 

c:> file1.txt

Note that file name should have the extension as .txt otherwise command prompt would not be able to identify which application need to be used to open the file.

9 comments… add one

  • sumit

    .\filename.txt
    then hit enter.

    Reply
    Link

  • Suman Ghosh

    more filename

    Reply
    Link

  • Marvi Sharma

    Thank you. Your material proved to be very helpful.

    Reply
    Link

  • Nkavelo

    I’m struggling to open a two word file.
    Some files have underscores and hyphens, how do I open those?

    Reply
    Link

    • Anonymous

      Write ” Around the address name.
      Example:

      “C:\Users\User 1\Downloads\ChromeSetup.exe”

      Link

  • vikaz baig

    which command is used to show the contents of text file?

    Reply
    Link

    • No One Special

      In command prompt, use the command TYPE to view the contents of the text file.

      i.e. type C:\windows\system32\drivers\etc\hosts

      Link

  • Microsoft Help

    This is a good way to create a Msge box in CMD

    Reply
    Link

  • Mujaahid

    how to open many file and folder to text editor with terminal?, example i want to open laravel framework to text editor

    Reply
    Link

Leave a Comment

Name *

Email *

Website

Comment

Current ye@r *

More Recent Posts

  • Add new user account from command line (CMD)
  • Delete directory from command line [Rmdir]
  • TaskKill: Kill process from command line (CMD)
  • Kill Chrome from command line
  • Find windows OS version from command line
  • How to check if Windows 32 or 64 bit?
  • Get Windows install date
  • User questions about fixing javac not recognized error
  • How to Kill process from PowerShell
  • Fix WMIC invalid alias verb error

E-mail Newsletter

Categories

  • Automation (2)
  • Batch Files (9)
  • Command Line Errors (2)
  • Command prompt (3)
  • Directories (5)
  • Download (1)
  • Files (31)
  • Java (2)
  • Network (6)
  • PowerShell (5)
  • Remote access (7)
  • Run commands (28)
  • System Configuration (28)
  • System information (21)
  • Uncategorized (43)
  • User Accounts (23)
  • User Settings (9)
  • Windows Commands (34)
  • Windows shortcuts (4)
  • WMIC (1)

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как открыть настройки звука на windows 10 сочетание клавиш
  • Где посмотреть время работы windows
  • Geforce driver windows server 2012
  • Как сделать проверку жесткого диска на windows 10
  • Как подсоединить принтер к компьютеру windows 7 без диска