• How to run a program from the command line. Installing the program from the command line. Installing the program via the command line. Run the file from the command line. Running Windows programs from the command line and cmd files

    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 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 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:


    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:


    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. 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.

    Absolutely all programs can be launched from command line. This feature appeared in the first operating systems, including the line Microsoft systems Windows. Previously, operating windows were a continuous command line ( MS-DOS system). Today, many program developers include in their distribution the ability to run as a single file using the command line.

    You will need

    Instructions

  • To simply launch the program from the command line, you need to do the following:
  • Click the "Start" menu - select "All Programs" - "Accessories" - "Command Prompt";

    In the window that opens, you need to return to drive “C”; to do this, at the end of the line, enter “cd..” and press Enter. Repeat this action several times until you completely move to the “C” drive;

    Enter the full path to the program you are running (C:\Program Files\KeyTweak\KeyTweak.exe).

  • You can also run the program with different parameters. These options are in addition to the actions performed by the program itself. Additional parameters look like an addition to the main program launch line.
  • Command line with additional parameters may look like this: “C:\Program Files\KeyTweak\KeyTweak.exe” u -r –y.
  • C:\Program Files\KeyTweak\KeyTweak.exe - full path to the Key Tweak program. Parameters used in this example Key programs Tweak:

    - "u" – quick start programs;

    - “-r” - restore last save changes;

    - “-y” - answer “Yes” to requests received from the system.

  • In order to create a cmd file you need to:
  • Create new text document with extension .txt.

    Write down the required set of commands.

    After completing these steps, run the file.

    From the command line, you can run the program installation in interactive or silent mode.

    Also, when installing the program from the command line, you can configure a username and password to access the program. The program will ask for a username and password when the user tries to uninstall or stop it, or change its settings.

    Most of the time our programs work just as well as we need them to, but every now and then you have one that is less than co-op and leaves you with an opportunity to fix the "attitude" problem. Run it so that the window does not close.

    Control the same action using the command line. You can create batch file, containing two lines. You can create a shortcut with the above. There is no need to write down any paths. Anything to add to the explanation? Typically, programmers write stand-alone scripts that are independent of live environments. Once the interpreter is called, it reads and interprets the file. Then you have to make the script executable using the following command.

    To run the program installation wizard from the command line,

    Type setup.exe or msiexec /i at the command prompt.

    To install a program or update a program version in silent mode (without running the Program Installation Wizard),

    enter in the command line setup.exe /pEULA=1 /pKSN=1|0 /pINSTALLLEVEL= /pALLOWREBOOT=1|0 /pSKIPPRODUCTCHECK=1|0 /pSKIPPRODUCTCUNINSTALL=1|0 /s

    A message will appear on your screen. For example, loops are repeated immediately unless they are part of a function. So it requires some mental planning. This is not necessarily a simple question. The letter may be different, and there may be other things after it, so you could just as easily see something like.

    Installing the program via the command line

    Depending on how your computer is configured and what else you've recently done to it. The interpreter reads your script, compiles it into bytecodes, and then executes the bytecodes to run your program. Then you should see something like. You started the interpreter in "interactive mode". Test it by entering a few expressions of your choice and seeing the results. Many people use the interactive mode as a convenient, but very programmable calculator.

    msiexec /i EULA=1 KSN=1|0 INSTALLLEVEL= ALLOWREBOOT=1|0 ADDLOCAL= SKIPPRODUCTCHECK=1|0 SKIPPRODUCTCHECK=1|0 SKIPPRODUCTCUNINSTALL=1|0 /qn ,

    • EULA=1 means you accept the terms License Agreement. The text of the License Agreement is included in. Acceptance of the provisions of the License Agreement constitutes a necessary condition to install a program or update a program version. If this parameter is not specified during a silent installation, the program will not be installed.
    • KSN=1|0 means consent (1) or refusal (0) to participate in the Kaspersky Security Network program (hereinafter also “KSN”). The text of the Regulations on Participation in KSN is included in the Kaspersky package. Endpoint Security. Specifying a parameter value is optional. If the value of the KSN parameter is not specified in the command, then when Kaspersky Endpoint Security is launched for the first time, a window will open asking you to participate in the KSN program.
    • INSTALLLEVEL= indicates the installation type of Kaspersky Endpoint Security. Specifying a parameter value is optional. If the command does not specify a value for the INSTALLLEVEL parameter, the default installation of the program is performed.

      Instead, you can specify the following values ​​for the INSTALLLEVEL parameter:

      Starts the interpreter as above. Once you've checked the directory, you need to add it to the startup routines your computer goes through. Note that if you have sufficient privileges, you may have the choice of setting options for either the current user or the system.

      If you are unsure about doing any of these steps yourself, get help! At this point, you can reboot your system to ensure the new setting has taken effect. A session to run this program might look like this. If you didn't want to change the current directory.

      • 100. In progress basic installation programs.
      • 200. The standard installation of the program is performed.
      • 300. All program components are installed.
    • ALLOWREBOOT=1|0 means consent (1) or prohibition (0) to automatically reboot the computer if it is required after installing or updating the program. Specifying a parameter value is optional. If the command does not specify a value for the ALLOWREBOOT parameter, the default automatic reboot computer after installing or updating the program is prohibited.

      You may need to restart your computer after updating the program version or if third-party anti-virus software is detected and removed during the installation of Kaspersky Endpoint Security.

      It's important to remember. Interactive mode is best used for testing that individual statements and expressions do what you think they do and for developing code through experimentation. This entry. First create new folder, in which we can save our program.

      IN text editor enter the following. Open new terminal and enter the following. Let's look at this program in more detail. The first line says this. This is called a package declaration. Packages are a way to organize and reuse code. Executable applications are those types of programs that we can run directly from the terminal.

    • ADDLOCAL= specifies which components should be installed in addition to those selected by default in standard installation mode. Specifying a parameter value is optional.

      Instead, you can specify the following values ​​for the ADDLOCAL parameter:

      • MSBitLockerFeature. The Microsoft BitLocker Manager component is being installed.
      • AntiAPTFeature. The KATA Endpoint Sensor component is being installed.
    • SKIPPRODUCTCHECK=1|0 means enable (1) or disable (0) checking for incompatible software. Specifying a parameter value is optional. If the SKIPPRODUCTCHECK parameter is not specified in the command, by default Kaspersky Endpoint Security scans and displays a list of detected incompatible programs.
    • SKIPPRODUCTUNINSTALL=1|0 means consent (1) or prohibition (0) to automatic removal found programs that are incompatible with Kaspersky Endpoint Security. Specifying a parameter value is optional. If the SKIPPRODUCTUNINSTALL parameter is not specified in the command, by default Kaspersky Endpoint Security tries to remove all found incompatible programs.

    To install the program or update the version of the program with a user name and password confirming the right to change program parameters and operate the program, follow these steps:

    Libraries are collections of code that we put together so that we can use them in other programs. We'll look at libraries in more detail later, but for now just include this line in any program you write. The next line is an empty line. Computers render symbols new line with special character. New lines, spaces, and tabs are called spaces. Go mostly don't care about spaces, we use it to make programs easier to read.

    Using double quotes like this is known as a "string literal", which is a type of "expression". Lines are described in more detail in the next chapter, but for now it's important to remember that in the opening "the character must eventually be followed by another" character, and everything in between is included in the line. After this you will see the function declaration.

    • If you want to install a program or update a version of a program interactively, enter the following command at the command prompt:

      setup.exe /pKLLOGIN=

      msiexec /i KLLOGIN= KLPASSWD=***** KLPASSWDAREA= .

    • If you want to install a program or update a version of a program in silent mode, enter the following command at the command prompt:

      setup.exe /pEULA=1 /pKSN=1|0 /pINSTALLLEVEL= /pKLLOGIN= /pKLPASSWD=***** /pKLPASSWDAREA= /s

      They have inputs, outputs, and a series of steps called operations that are performed in order. This function has no parameters, returns nothing, and has only one statement. The main name function is special because it is a function called when the program is executed. The last part of our program is this line.

      This statement has three components. At this point we've already seen a lot of new terminology and you may be a little overwhelmed, sometimes it's helpful to consciously read your program out loud. One reading of the program we just wrote might look like this.

      msiexec /i EULA=1 KSN=1|0 INSTALLLEVEL= KLLOGIN= KLPASSWD=***** KLPASSWDAREA= ALLOWREBOOT=1|0/qn .

    Instead, you can specify one or more of the following values ​​for the KLPASSWDAREA parameter (separated by semicolons), corresponding to the operations that require confirmation:

    This function takes no arguments, returns nothing, and does the following: 1. You can find out more about this by typing the following in your terminal. Among other things, you should see this. Spaces are always added between operands and a new line is added.

    It returns the number of bytes written and the write error that occurred. Let's return to this function. Our program started with a basic package. . First download and install node. How you do this depends on the type of machine and operating system. Once node is installed, you can test your installation by entering the following at the command prompt.

    • SET. Changing program parameters.
    • EXIT. Termination of the program.
    • DISPROTECT. Disable protection components and stop scanning tasks.
    • DISPOLICY. Turn off policy Kaspersky Security Center.
    • DISCTRL. Turning off control components.
    • REMOVELIC. Deleting a key.
    • UNINST. Removing, changing or restoring a program.
    • REPORTS. View reports.

    When installing a program or updating a program version, silent mode supports the use of the following files:

    How to launch any application via the command line

    This will respond to the version number of the version you just installed. The shell is great for practice, but we want to write programs, store them in files, and execute them on demand. Node's built-in console object allows you to write to the terminal. Technically it allows you to record your system's standard output and standard error streams, but we'll get to that later. Running your program is as simple as calling node on the file containing your program.

    Here's a couple simple applications, which seem to appear in introductory programming lessons. The first shows the powers of the two. And here is a simple program to record the first few lines of Pascal's famous triangle. And here is a program that generates a random hand of five card games every time it is run.

    • setup.ini containing general parameters installing the program;
    • configuration file install.cfg containing operating parameters for Kaspersky Endpoint Security;
    • setup.reg containing registry keys.

    The setup.ini, install.cfg and setup.reg files must be located in the same folder with the distribution package of Kaspersky Endpoint Security 10 Service Pack 2 for Windows.

    Of course, programs launched from the command line must have access to their arguments. For example, if we enter the following. If your script takes more than one or two command line arguments, we strongly recommend that you create named input arguments and use a command line parser. A large number of parameter parsers are available for the node; choose any one you like.

    If they were allowed to do this, you could be taken to a malicious site that hosted a script that searched your file system for personal information and sent whatever it found back to its original server. And of course browser scripts can't write to your file system.

    This documentation has been archived and is no longer maintained.

    Installation from the command line - specifying parameters

    Applicable to: Forefront Protection for Exchange

    Section modified date: 2010-05-10

    The following table summarizes the options that you can use when you run the extracted installation package (setup.exe) from a command line:

    You can probably guess why not. However, the node allows you to read and write files. Let's give just one simple example. So this was a pretty quick introduction to using node to write command line scripts, but we've barely scratched the surface of what node is and what it can do.

    Especially in older installations, startup becomes more and more delayed as new programs are launched. If there are multiple programs in the Startup menu, the download process will take longer. The tool can launch programs and autorun tools with a delay, thereby solving system stutters caused by simultaneous programs. You need to take action. Once selected, the wizard installs the selected functions. The toolkit creates a log file from the analysis, which you can read later to detect system slowdowns.

    Parameter Description Requirements

    Installation without user intervention - does not appear on the screen

    Required parameter /a

    Optional parameter /c

    This works for every letter in every directory. Therefore, you should stop all programs that you are running before. This is the only way to ensure that all instruments and drivers are captured. In some cases, you may receive error messages in the form The user mode logger cannot be found in the active list of loggers. If this doesn't work, you can't use the toolkit for further analysis, or at least be limited, or with some extra work.

    First analysis of the boot process

    We'll show you how to do it. Loading. However, this is not particularly important for analysis, but only serves for later comparison. A file with kernel data, that is, the beginning of the operating system and a file with user data. You can filter the display by the menu area, which is displayed by clicking on the left side of the window. To do this, click the icon to the left of the middle of the window. Various measurement ranges are currently available. If you uncheck the checkbox, the corresponding chart in the viewer will also disappear.

    Passive installation - no prompts to the user, but displays progress

    Required parameter /a

    Optional parameter /c

    /aPathtoAnswerFile

    Specifies a required response file

    Answer file is required

    This way you can hide exactly what you need. The display is dynamic, which means you can hide hidden charts at any time and vice versa. Select a specific area and right-click on it. Then select PivotTable. Now you see in the table that the processes are delaying the start. If you click on the chart on the chart, you can zoom in on part of the ad. To do this, select the area with your mouse that you want to zoom in on and right-click. Use the "Scale to Select" menu command to initiate the scaling operation.

    /q or /p

    [/cPathtoConfigFile]

    Specifies an optional configuration file

    Configuration file is required

    Valid only with parameters /q or /p

    Before performing a passive or silent installation, you must extract the setup.exe file using the following command:

    In addition to graphics, you can also create tables for other areas by selecting " Pivot table" V context menu. The table shows information similar to Task Manager during the measured period. You can sort the view by clicking the appropriate column in the table. If you don't recognize the process, search for the executable file using a search engine.

    This way you will quickly discover the processes that are delaying the start. You should remove them from startup as much as possible to speed up system startup. However, keep in mind that some programs may stop working if you disable AutoPlay features. In the context menu of entries and selecting Internet search, you can start searching through the program on the Internet. You don't need to install this tool, but you can run it directly. The “Login” tab is also important. Here you can see entries starting with the user's login.

    frontexchangesetup.exe /x: extractpath

    Silent installation allows you to run scripts during installation of Microsoft Forefront Protection 2010 for Exchange Server (FPE). This type of installation does not display any notifications about the installation status. All output is written to the installation log, program log, or event log. Silent installation can be used to perform automated and distributed installations on . Silent installation requires a response file, which is provided using the /a. A response file template that can be modified to suit your specific environment is provided in installation package along with an XML Schema (XSD file) that you can use to validate the resulting response file. If a valid response file is not provided, the installation is aborted and errors are logged. For information about viewing a sample answer file, see.

    After extracting the installation package ( additional information see section) you can run a silent installation with an answer file by entering the following at the command line:

    setup.exe /q /a PathtoAnswerFile

    The answer file contains answers to any questions you may have during the installation. This is a required parameter. In addition, you can specify the parameter /c

    setup.exe /q /a PathtoAnswerFile/

    Passive installation works in the same way as silent installation, but it displays a progress bar to show the installation progress.

    After you extract the installation package (see the section for more information), you can run the passive installation with the answer file by entering the following at the command prompt:

    setup.exe /p /a PathtoAnswerFile

    The answer file contains answers to any questions you may have during the installation. This is a required parameter. (See the section for information about viewing a sample answer file.) In addition, you can specify the parameter /c, which allows you to optionally import configuration settings to the server after installation is complete. These are settings that were exported from another server. The syntax should be as follows:

    setup.exe /p /a PathtoAnswerFile/

    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 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.

    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 of the components 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 in 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 required file 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.

    This doesn't work on the command line. 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.