Bat файл. / Bat files.

Файл bat или командный файл - обычно с расширением .cmd или .bat представляет собой набор из команд для выполнения рутинных операций.

Например, для установки набора  программного обеспечения на ваш компьютер можно воспользоваться командным файлом, в котором, будут прописаны исполняемые .exe файлы или .msi файлы с ключами тихой установки.

Для того, чтобы запустив командный файл вы спокойно, пошли и занялись другими делами пока устанавливается программное обеспечение на ваш компьютер.

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

Ниже мы рассмотрим пример создания командного файла для установки программного обеспечения и для установки настроек.

Для многих ИТ администраторов, работников технической поддержки командные файлы являются помощниками и оптимизируют их работу.

Большинство командных файлов пишется в обычных текстовых редакторах. Наверное, самым популярным является notepad который встроен в операционную систему.

Командный файл ещё называют скриптом, а создание командных файлов скриптованием.

Давайте рассмотрим пример создания командного файла для установки программного обеспечения:

Откройте блокнот. Нажмите Пуск – Все программы – Стандартные и откройте Блокнот

 

Скачайте необходимые программы и разместите их в папке где будет командный файл.

В рассматриваемом примере будет использоваться архиватор 7zip и FlashPlayer. О ключах тихой установки данного приложения можно посмотреть на сайте в разделе:

Автоматизация установки приложений

В окне блокнота необходимо прописать .exe файлы и ключи для тихой установки.

Notepad example

 

Рассмотрим пример с изображения построчно:

echo Install Archivator 7Zip – Простой вывод текста в командную строку. В нашем случае - выводится информация о начале установки архиватора 7zip.

%~dp07z1604-x64.exe /S – Установка самой программы. Где %~dp0 это переменная текущей папки, 7z1604-x64.exe – название дистрибутива, /S – ключ тихой установки.

ВАЖНО ! Если вы создали папку для дистрибутивов с пробелом (Например - Soft Install), то необходимо заключать строку %~dp07z1604-x64.exe в кавычки, то есть "%~dp07z1604-x64.exe"

echo Install FlashPlayer ActiveX – Аналогично вывод текста в командную строку о начале установки программы FlashPlayer.

%~dp0install_flash_player_ax.exe –install Установка программы, где %~dp0вам уже понятное значение (текущая папка), install_flash_player_ax.exe название дистрибутива, –installпараметр для тихой установки.

 

Сохраните файл, выбрав в блокноте – ФайлСохранить как

В открывшемся окне “Сохранить как” выберите папку где расположены ваши дистрибутивы, тип файла: Все файлы и назовите его либо как в примере, либо любое другое название, но обязательно с расширением .cmd или .bat

example save type


Результатом выполнения данного скрипта станет установка Архиватора 7-zip и FlashPlayer.

Вы можете масштабировать решение и устанавливать большой набор программ на вашем компьютере или компьютерах офиса.

А  еще можно воспользоваться программой Remote Install Application которая доступна по ссылке:

http://regedit.su/remote-install-app

С помощью данной программы вы сможете установить программы на удаленный компьютер.

Рассмотрим пример установки настройки операционной системы для включения удаленного рабочего стола.

 

Запустите Блокнот и скопируйте в него данные строки:

echo RDP enable

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

example reg file


Где:

reg add – добавить значение в реестр

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server"Путь в реестре

/v fDenyTSConnections – указание параметра в реестре

/t REG_DWORD – Указание типа значения

/d 0 – Установка значения для параметра в реестре

/f – Подавлять запрос на подтверждение, если параметр существует

Сохраните файл с расширением .cmd или .bat

Результатом выполнения будет установка параметра в реестре, который включит "Удаленный рабочий стол" если он выключен.

 

 

Bat file or Command file - usually with extension .cmd or .bat is a set of commands to perform routine operations.

For example, to install a set of software on your computer, you can use the command file, which will be registered executable .exe or files .msi files with silent installation keys.

To run the command file you calmly, go and do other things while the software is installed on your computer.

The command file can be used to set the settings of both the operating system and the software.

Below we will look at an example of creating a command file to install the software and to install the settings.

For many it administrators, technical support workers, team files are assistants and optimize their work.

Most command files are written in plain text editors. Probably the most popular is notepad which is built into the operating system.

A command file is also called a script, and the creation of command files by scripting.

Let's look at an example of creating a command file for software installation:

Open the notepad. To do this, click StartAll programsAccessories and open Notepad

Download the necessary programs and place them in the folder where the command file will be

In this example, you will use the archiver 7-Zip and FlashPlayer about the keys of silent installation of this application can be found on this website in the section – Silent installation of application.

In Notepad window typed .exe files and keys for silent installation

example notepad eng

 

Consider the example from the image line by line:

echo Install Archivator 7Zip – Simple text output to the command line. In our case-displays information about the beginning of the installation of the archiver 7zip.

%~dp07z1604-x64.exe /S - Installation of the program. Where %~dp0 is the current folder variable, 7z1604-x64.exe is the name of the distribution, /S is the silent installation key.

IMPORTANT ! If you have created a folder for distributions with a space (example Soft Install), you must enclose the line %~dp07z1604-x64.exe in quotes, that is "%~dp07z1604-x64.exe"

echo Install FlashPlayer ActiveX – Similarly, the output of text to the command line about the beginning of the installation FlashPlayer programs.

 

%~dp0install_flash_player_ax.exe –install - Installation of the program, where %~dp0 - you already understand the value (current folder), install_flash_player_ax.exe - name of the distribution, -install - parameter for silent installation.

Save the file by selecting Notepad – File - Save as


In the “Save as” window that opens, select the folder where your distributions are located, the file type: All files and name it either as in the example, or any other name, but with the extension .cmd or .bat

example save typeeng

The result of this script will install the Archiver 7-Zip and FlashPlayer.

You can scale the solution and install a large set of programs on your computer or office computers.

And you can still use the program Remote Install Application which is available here:

 

http://regedit.su/remote-install-app

With this program, you can install programs on a remote computer.

Let's look at an example of setting up the operating system to enable remote desktop.

Start Notepad and paste the line data from this:

echo RDP enable

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

example reg fileeng

Where:

reg add - to add a value to the registry

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" - Registry path

/v fDenyTSConnections - specifying a parameter in the registry.

/t REG_DWORD - Specifying the value type.

/d 0 - Setting a value for a parameter in the registry.

/f - To suppress the confirmation prompt if the parameter exists.

The result is a registry setting that will enable Remote desktop if it is turned off.

Обновлено 13.11.2018 10:22  
Интересная статья? Поделись ей с другими:

Операционные системы

Сообщество в VK / COMMUNITY in VK


  • Вопросы по поводу написанных статей можно обсудить в нашем сообществе в Вконтакте / Questions about written articles can be discussed in our community in Vkontakte Вопросы по поводу написанных статей можно обсудить в нашем сообществе в  Вконтакте / Questions about written articles can be discussed in our community in Vkontakte
Яндекс.Метрика