• How to run a program from the command line: three easy ways. Run the file from the command line. Running Windows programs from the command line and cmd files

    Dear friends, it's no secret that users working on Linux based, always turn up their noses at those who work on Windows. They say that for Windows you need to install the application for at least 10 minutes by clicking large number buttons, fiddling with the selection checkboxes. And before you actually install the application, you need to find the official website of the program without getting lost on the Internet. Linux users are proud that they can install any utility from the terminal by executing a certain command.

    In Windows, like in Linux, it is possible to install, remove or edit programs using commands.

    The developers claim that Windows 10 will also have the ability to quick installation, updates and deletions various support from the system terminal. We just have to wait for the official release. But you don’t have to wait for the release, but right now take advantage of an amazing feature that will allow the user to install the program from the command line. However, this is not all the surprises: the utility will also allow you to delete, update, open and close the program. Interesting? Let's get to know Chocolatey better.

    Installing the program via the command line

    Now we will try to manage programs more conveniently and very in a similar way on how this is done in Linux environment. And it will help us with this special service Chocolatey, package manager for Windows. The Chocolatey client is a utility designed to run in the console. Let's try to install it right away. To install, open a terminal with administrator rights. Right-click on the Start menu and click on Command Prompt (with administrator rights). Now let's copy the following code:

    @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE% \chocolatey\bin

    Paste it in and press the Enter key. Now you need to close the console so that the data on the variables is refreshed.

    The Chocolatey service has a large catalog of utilities and applications: at the moment more than 2000 utilities. You can view them on the official website https://chocolatey.org/packages. So, it's time to learn how to install any program via the command line:

    Open the terminal again as administrator. We copy the text presented to the right of the program on the website https://chocolatey.org/packages. For example, to install a browser Google Chrome the following code is presented:

    choco install googlechrome -y

    Copy it and paste it into the terminal. Don’t forget to write the combination -y after the code from the site. Press Enter. Now all that remains is to wait for the browser installation to complete. After which you can close the terminal window.

    As you might have noticed, Google browser Chrome installed very quickly. We didn't have to click any buttons or select a location to save the files (disk C is used by default). By the way, novice users can make a set of their favorite applications in a notepad, so as not to go to the Chocolatey service every time. To uninstall a program via the command line, enter the code uninstall, then the name of the program. For example, choco unistall ccleaner.

    ATTENTION. The service only works with packages that are installed through it. That is, if any software is not available for installation through Chocolatey, then you will not be able to remove it this way.

    How to run or uninstall a program via the command line

    Now let's look at a method that allows through the command line. This can be done in three very simple steps. Let's get started:

    1. Open the terminal operating system Windows.
    2. In the window that appears, write the full path to the location of the application launch file. For example, D:/Files/chrome.exe
    3. We press Enter and wait for the system to open what we need.

    It's time to learn how to close a program via the command line. For this we need additional taskkill software. Let's start:


    Let's sum it up

    Dear readers, today we examined what seemed, at first glance, to be a complex topic. But now you know that you can very easily install or uninstall some programs through the command line using the Chocolatey service. And you also know how to open or close an application through the same terminal. We hope that you managed to do everything correctly and that there are no questions left on the topic. Tell us your opinion and impressions in the comments!

    Indispensable in case of computer failures. Getting started with skills usually involves working on how to open, copy, run, delete a file. You can see below what the algorithm of actions will look like for each component of the work. Let's start with the question of how to open a file via the command line, then we'll show you how to delete them and copy a piece of text. A beginner can handle these tasks, but for those who have been working with a computer for a long time, it is useful to remember or study these options for carrying out common processes.

    In the team Windows line You can fully work with files.

    Sometimes you can’t open files through Manager or Explorer, then the command line will help you. You just need to remember a few commands.

    So, you have launched the program and want to open one of the documents. Follow this algorithm.


    Subsequently, having remembered the path, in order to launch it, you will not need to go to the directory; you just need to enter the full path in the line.

    ADVICE. To make work faster, there are bat files; commands that are needed and often typed are written into them in advance. Then this file is launched, and it will open the desired program.

    Launching and closing programs

    Let's look at how to run a file from the command line if it is a program file. What will matter here is whether the application is included in Windows package or did you need third party application. If the application you are opening is part of Windows components, launch is done by entering its name into the console, then pressing Enter. The extension is not required. Let's say you need to launch Notepad, then just type the word notepad and then press Enter.

    If the program is third-party, you should enter the full path to it. For example, you needed to launch WinRAR archiver, then you enter the following:

    C:\Program Files\WinRAR\WinRAR.exe

    Write the path in quotes if the address contains spaces. In this case, quotation marks are needed straight - not in the form of commas. If the quotes are incorrect, the program will not open. You do not need to copy the quotes; you type them directly into the command line, without using the clipboard. On the English layout, the necessary quotation marks are in combination Shift keys+ E.

    ADVICE. If you go to the directory with the program, you do not need to enter the full path to it. Simply enter the file name with extension. For example, going to the WinRAR directory, enter the command WinRAR.exe - the program will launch.

    To close applications, use the taskkill program. First, type tasklist, a list of processes will appear for your viewing. Enter the indicator number in the command, for example “taskkill /pid 3900/f”, press Enter to confirm. 3900 is the ID number.

    Search by extension

    The command line will help you find the file you need by its extension if you don’t remember its exact name. To find a file via the command line, you need to remember the command used in this case. Type dir and the extension you need separated by an asterisk. Let's say you are looking for one of the executable files, so you type:

    All files with this extension will be displayed on the screen, you just have to find the one you need among them. If you need to search in subdirectories, add the “/S” key. Full team to search for a file in drive C, including searching in subdirectories, would look like this:

    Removal

    Remove unnecessary ones system files It is also possible through the program in question. Deleting a file via the command line is easy. To delete, use the del command. After it, the path to the required document is written. For example, you want to delete 123.txt. Enter the following: “del C:\Windows\123.txt”.

    IMPORTANT. To completely clear a folder, use the “/S” attribute. With this key you can delete any nested directories and all data.

    Copy text

    OS Windows, taking care of speeding up and making work on a PC easier, has created hot keys - combinations that allow you to quickly copy text and paste it into another file. These are the combinations Ctrl+V or Shift+Insert.

    IN command line it doesn't work. To copy information in it, you must first configure it.


    Now, to copy a piece of text from the command line, select it with the mouse and press Ctrl+C.

    All these skills will be useful to you if you cannot complete the desired process in the usual way due to failures or computer problems. Simple steps, an easy-to-remember algorithm, clear instructions - everything helps you solve the questions posed more professionally. You just need to remember the list of commands, follow the rules for entering them (for example, when to put quotes and which ones), clearly and accurately enter the path to the required file.

    It's no secret that Linux users always turn up their noses at those who work on Windows. They say that for Windows you need to install the application for at least 10 minutes, pressing a large number of buttons, fiddling with selection checkboxes. And before you actually install the application, you need to find the official website of the program without getting lost on the Internet. Linux users are proud that any utility
    can install from the terminal by running a certain command.

    In Windows, like in Linux, it is possible to install, remove or edit programs using commands.

    The developers claim that Windows 10 will also offer the ability to quickly install, update, and remove various software from the system terminal. We just have to wait for the official release. But you don’t have to wait for the release, but right now take advantage of an amazing feature that will allow the user to install the program from the command line. However, this is not all the surprises: the utility will also allow you to delete, update, open and close the program. Interesting? Let's get to know Chocolatey better.

    Installing the program via the command line

    Now we will try to manage programs in a more convenient way and very similar to how it is done in the Linux environment. And a special service called Chocolatey, a package manager for Windows, will help us with this. The Chocolatey client is a utility designed to run in the console. Let's try to install it right away. To install, open a terminal with administrator rights. Right-click on the Start menu and click on Command Prompt (with administrator rights). Now let's copy the following code:


    Paste it in and press the Enter key. Now you need to close the console so that the data on the variables is refreshed.

    The Chocolatey service has a large catalog of utilities and applications: currently more than 2000 utilities. You can view them on the official website https://chocolatey.org/packages. So, it's time to learn how to install any program via the command line:

    Open the terminal again as administrator. We copy the text presented to the right of the program on the website https://chocolatey.org/packages. For example, to install the Google Chrome browser, the following code is provided:


    Copy it and paste it into the terminal. Don’t forget to write the combination -y after the code from the site. Press Enter. Now all that remains is to wait for the browser installation to complete. After which you can close the terminal window.

    As you can see, the Google Chrome browser installed very quickly. We didn't have to click any buttons or select a location to save the files (disk C is used by default). By the way, novice users can make a set of their favorite applications in a notepad, so as not to go to the Chocolatey service every time. To uninstall a program via the command line, enter the code uninstall, then the name of the program. For example, choco unistall ccleaner.

    ATTENTION. The service only works with packages that are installed through it. That is, if any software is not available for installation through Chocolatey, then you will not be able to remove it this way.

    How to run or uninstall a program via the command line

    Now let's look at a method that allows through the command line. This can be done in three very simple steps. Let's get started:

    1. Opening the operating terminal Windows systems.
    2. In the window that appears, write the full path to the location of the application launch file. For example, D:/Files/chrome.exe
    3. We press Enter and wait for the system to open what we need.

    It's time to learn how to close a program via the command line. For this we need additional taskkill software. Let's start:



    Let's sum it up

    Today we looked at what seemed, at first glance, to be a complex topic. But now you know that you can very easily install or uninstall some programs through the command line using the Chocolatey service. And you also know how to open or close an application through the same terminal. We hope that you managed to do everything correctly and that there are no questions left on the topic.

    Team START allows you to run applications in a separate window, with the ability to specify some parameters for their execution.

    Command line format:

    START ["header"] [command/program] [parameters]

    Command line options:

    "heading"- window title. Must be in double quotes.

    path- working directory.

    B- launching the application without creating a new window and disabling processing of the CTRL+C key combination. If an application does not handle CTRL+C itself, the only way to break it is to use CTRL+Break.

    I- The new environment will be the original environment passed to cmd.exe, not the current environment.

    MIN- Run a command/program in a minimized window.

    MAX- Launch a command/program in a maximized window.

    SEPARATE- Run a 16-bit Windows program in a separate memory area.

    SHARED- Running a 16-bit Windows program in a shared memory area.

    LOW- Launch the application with IDLE priority (lowest priority).

    NORMAL- Launch the application with NORMAL priority.

    HIGH- Launch the application with priority HIGH.

    REALTIME- Launch the application with priority REALTIME (highest priority).

    WAIT- Launching an application and waiting for it to complete.

    ABOVENORMAL- Launching an application with priority class ABOVENORMAL (higher than standard)

    BELOWNORMAL- Launching an application with a BELOWNORMAL priority class (lower than standard)

    team/program- If this internal team cmd.exe or batch file, the command processor (cmd.exe) is launched with the /K switch. This means that the window will not be closed after the command completes. If it is not a cmd.exe internal command or a batch file, then it is a program that will be launched in a graphics or text window.

    parameters- Parameters passed to the command/program.

    To call non-executable files through the file type mapping mechanism, simply enter the file name on the command line. For example, the command

    START MYFILE.TXT

    Will trigger text editor NOTEPAD with opening the MYFILE.TXT file. Learn about creating similar mappings from batch files See the ASSOC and FTYPE command descriptions.

    When running a 32-bit application with graphical interface The user command handler CMD.EXE does not wait for the application to exit before returning to the command prompt. This new behavior does NOT apply to running applications from batch files.

    When executing a command line whose first element is the text string "CMD" without extension file name or specifying a path, it is replaced by the value of the COMSPEC variable. This prevents launch CMD.EXE from the current active folder, if such a program exists there.

    If the first command line item does not contain a file name extension, the command handler CMD.EXE uses the value environment variable PATHEXT to define executable file name extensions and search order the desired file. By default, the PATHEXT variable is set to:

    COM;.EXE;.BAT;.CMD

    Note that this syntax is similar to the syntax for the PATH variable, i.e. individual elements separated by semicolons.

    If no extension is matched when searching for an executable file, a match is checked specified name folders. If the folder name matches the one specified, the START command runs EXPLORER for that path. If this action is performed from the command line, it is equivalent to running the CD /D command on the specified path. So, for example, the command

    start C:\windows

    Opens the C:\windows folder in an Explorer window.

    Examples of use:

    start /?- issue a certificate about the use of the command.

    start- when launched without parameters, a new CMD command interpreter window will open.

    start "My new CMD window"- as in the previous case, CMD will be launched in a new window, but text will be displayed as the window title My new CMD window

    start devmgmt.msc- the extension will be launched .msc Windows Device Manager.

    start http://google.com- the Internet browser will launch and the Google search engine page will open.

    start mailto: [email protected] - launch will be completed mail client in preparation mode email for address [email protected] .

    start /min notepad.exe- Notepad will be launched in a minimized window.

    start "Backup Files" /min /belownormal mybackup.bat- launch batch file in a minimized window with reduced priority.

    start /abovenormal /MAX winword.exe- launch the editor Microsoft Word in a new window, maximized to full screen and with higher priority.

    start "" /high /MAX "C:\Program Files\Good game\MyGame"- launching the program MyGame with high priority.

    Priority management is convenient to use to ensure comfortable user experience with interactive applications against the backdrop of performing long-term calculation tasks. So, for example, equal priorities of the MS Word editor and a calculation task that consumes a significant share of resources central processor, there may be a freezing effect when working with text document. Reducing the priority of the calculation task will create normal conditions for the user’s work against the background of her work.

    Please note that the window title can be omitted, but the peculiarity of processing input parameters by the command start may produce unexpected results when attempting to run a program whose name or path contains space(s). For example, if you try to run the following command:

    start "C:\Program Files\FAR\FAR.EXE"

    Due to a space in the path to executable file, the line to run FAR.EXE must be enclosed in double quotes, but the format of the input parameters for start assumes the window title is also enclosed in double quotes, causing "C:\Program Files\FAR\FAR.EXE" to be interpreted as something other than executable program, and as the window title - the interpreter will be launched CMD with the window title "C:\Program Files\FAR\FAR.EXE" . To prevent this from happening, you need to use any header, even empty:

    start "" "C:\Program Files\FAR\FAR.EXE"

    When running batch files using the command start, the command interpreter window (cmd.exe) is launched with the parameter /K, i.e., after executing the commands in the batch file, cmd.exe does not terminate. For example, there is a batch file test.bat the following content:

    ECHO TEST

    When running it with the command start test.bat will be fulfilled echo and the shell window will remain open, waiting for user input. This fact must be taken into account when using the command start in scenarios that are executed automatically without human operator intervention. To close a window CMD After executing the batch file, just add the command to the end of it EXIT.

    Users of the Windows operating system are accustomed to launching all programs by double click left mouse click on their icons. However, few people know that the same action can be performed in the system console. This article will talk about how to run a c program through the command line. Let's look at three methods in total. And at the end we will provide a method that allows you to run the program through a shortcut, but with console parameters.

    How to run a program from the command line?

    It’s worth saying right away that all the methods described below are mostly similar. However, the command line is a specific tool, and depending on what attributes you use to open the application, the properties of the latter will change.

    Method 1: Launch a system application

    First of all, we'll tell you how to run the program from the command line, if it is a system program. This is perhaps the simplest method, since to perform it you only need to know one command - start. And, of course, the name of the application itself. The most popular ones will be listed below system programs:

    As a result for launch specific program you need to write the word start and enter its name separated by a space. In practice it looks like this:

    Start control

    Method 2: Specify the full path to the file

    Unfortunately, you won’t be able to launch a program from a third-party developer using the previous method, but there is another method. It consists of entering the full path to the executable file. For example, on your system disk C contains an installer for some program called install.exe. To run it, you will need to enter the following command:

    C:\install.exe

    Accordingly, if the file is located in another folder, then in the line you need to enter all the directories that come before the file. By the way, it is very important that there are no spaces in the folder names. Otherwise an error will appear. Eliminating it is quite simple - you need to put the entire path in quotes. For example:

    "C:\folder path with spaces\executable file.exe"

    Method 3: using path

    The third way to run a program from the command line involves using the patch command. Its essence is to remember the specified directory. That is, you need to enter the address not to the file itself, but to the folder where it is located. For example, you need to open Total Commander, which is located at the following address:

    C:\program files\total commander

    Then enter the following command in the console:

    Patch "c:\program files\total commander"

    The command line will remember the directory you specified and will run all files from it if you enter their name. Thus, to launch Total Commander, all you have to do is write its name:

    Totalcmd

    How to run a program with command line parameters?

    Now let's move directly to how to launch an application with console parameters. By the way, this is done quite simply, you don’t even have to open the command line - everything is done in the shortcut properties.

    1. Right-click on the program shortcut.
    2. Select "Properties".
    3. Go to the "Shortcut" tab.
    4. In the "Object" field, add required parameter after the quotes.
    5. Click apply and close the window.

    Now the program will start with specified parameter, you just need to double-click on its shortcut. So we looked at all the ways you can run a program from the command line. Well, it’s up to you to decide which one to use.