How to create environment variable windows 10

Изучаем переменные среды в Windows 10

Переменные среды Windows

Получить информацию о существующих переменных можно в свойствах системы. Для этого кликаем по ярлыку Компьютера на рабочем столе правой кнопкой мыши и выбираем соответствующий пункт.

Переходим в «Дополнительные параметры».

В открывшемся окне с вкладкой «Дополнительно» нажимаем кнопку, указанную на скриншоте ниже.

Здесь мы видим два блока. Первый содержит пользовательские переменные, а второй системные.

Если требуется просмотреть весь перечень, запускаем «Командную строку» от имени администратора и выполняем команду (вводим и нажимаем ENTER).

На рабочем столе появится файл с названием «set.txt», в котором будут указаны все переменные окружения, имеющиеся в системе.

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

Примечание: регистр при написании переменных не важен. Path=path=PATH

Переменные PATH и PATHEXT

Если с обычными переменными все понятно (одна ссылка – одно значение), то эти две стоят особняком. При детальном рассмотрении видно, что они ссылаются сразу на несколько объектов. Давайте разберемся, как это работает.

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

система осуществит поиск по папкам, указанным в значении переменной, найдет и запустит соответствующую программу. Этим можно воспользоваться в своих целях двумя способами:

    Поместить необходимый файл в одну из указанных директорий. Полный список можно получить, выделив переменную и нажав «Изменить».


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

%SYSTEMROOT% определяет путь до папки «Windows» независимо от буквы диска.

Затем нажимаем ОК в окнах «Переменные среды» и «Свойства системы».

Для применения настроек, возможно, придется перезапустить «Проводник». Сделать это быстро можно так:

Открываем «Командную строку» и пишем команду

taskkill /F /IM explorer.exe

Все папки и «Панель задач» исчезнут. Далее снова запускаем «Проводник».

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

Теперь все файлы, помещенные в «C:\Script» можно будет открывать (запускать), введя только их название.

«PATHEXT», в свою очередь, дает возможность не указывать даже расширение файла, если оно прописано в ее значениях.

Читайте также:  System and maintenance windows

Принцип работы следующий: система перебирает расширения по очереди, пока не будет найден соответствующий объект, причем делает это в директориях, указанных в «PATH».

Создание переменных среды

Создаются переменные просто:

    Нажимаем кнопку «Создать». Сделать это можно как в пользовательском разделе, так и в системном.


Вводим имя, например, «desktop». Обратите внимание на то, чтобы такое название еще не было использовано (просмотрите списки).


В поле «Значение» указываем путь до папки «Рабочий стол».


Нажимаем ОК. Повторяем это действие во всех открытых окнах (см. выше).

  • Перезапускаем «Проводник» и консоль или целиком систему.
  • Готово, новая переменная создана, увидеть ее можно в соответствующем списке.

    Для примера переделаем команду, которую мы использовали для получения списка (самая первая в статье). Теперь нам вместо

    потребуется ввести только

    Заключение

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

    How To Create Custom Environment Variables in Windows 10

    Creating Custom Environment variables in windows helps you a lot because by creating your own variables saves your time. If you are using same path or directory again and again, it would be better to create a variable and provide it to the path of your directory and just use that variable instead of giving long paths or directory.

    You can say these variables as shortcuts to your apps. This can make you to move within Windows more quickly and easily.

    Types of Variables

    Basically there are two types of Environment Variable. one is System Variable and other is User Variable. both are combine to make environment of your System.

    System Variables

    the system Variable is termed as global variable and can be accessed or used by any user who uses the particular System.

    User Variables

    The User Variable is termed as specific variables, which is only be accessed to user who is currently logged in.

    Use of Environment Variables

    For example, if you have to go to User Profile, and you have created a System Variable with name “userprofile”. you don’t need to open File Explorer and then find the User Profile. Just simple access your Variable by typing “%userprofile%” into start menu.

    You’ll get your result on top first search. Click it and your profile will be opened to you.

    You have seen how much these variables are helpful. Now I am going to show you how can you create your own Custom Variables and give them Path to save your time and navigate speedily within your OS.

    Читайте также:  Очистить кэш windows update

    Creating User Defined Environment Variables

    Let’s create our own Custom Environment Variables. Firstly type “System Properties” in start menu and open the first result. Then go to “Advanced” tab and click on “Environment Variable” option.

    Now window of Environment Variable will be in front of you.

    Now click on “New” option under User Variables. The small window will appear that will ask you to enter “name” for your variable and “value” of variable. Variable means the path of the variable. In my case, I want to access my Company folder so I put address of that folder in Value of the new variable.

    And then press “OK”. And close the window. Now variable will be added into your System Variable list.

    Type “%Company%” in start menu. And you will get your desire result.

    Or open CMD and type “echo %Company%”, your value of variable will be shown on Command Line window.

    Creating your own customized variables can be super helpful in cases where you have to use a path again and again. What methods do you use as shortcuts for opening your favorite programs and folders?

    How to Set Environment Variables in Windows 10

    Windows 10 supports a number of legacy features from older versions of the operating system. One of those legacy features is the environment variable.

    Environment variables offer a useful way to control the way Windows operates with an extremely small footprint in terms of memory usage.

    For example, one common environment variable is called PATH, which is simply an ordered text string containing a list of directories that Windows should look in when an executable file is called.

    The PATH environment variable allows users to quickly launch programs without having to know where those programs live on the hard drive.

    Setting environment variables is very useful and, fortunately, very simple. In this article, we’ll go over how to find and set your environment variables in Windows 10.

    How Do I Set Environment Variables in Windows 10?

    Once logged in to Windows, right-click the Windows button in the lower-left corner of your screen. This will open up the Power User Tasks Menu.

    Depending on your settings, this process may open the Start menu instead. If it opens the Start menu, type “Windows-x on your keyboard to open the Power User Task Menu.

    Click System from the Power User Task Menu that’s displayed on the screen.

    Under the System menu, you need to click the Advanced System Settings.

    If you can’t find Advanced System Settings there, type “advanced system settings” into the search box and hit return to bring it up.

    Once Advanced System Settings is open, click on the Advanced tab, then look on the bottom-right side for the Environment Variables.

    Читайте также:  Флешка mac os x install

    Next, to create a new environment variable, click New.

    A dialog box will pop up, allowing you to enter a new variable name and to set its initial value:

    • New adds a new environment variable.
    • Edit lets you edit whatever environment variable you have selected.
    • Delete lets you delete the selected environment variable.

    Save any changes that you make by clicking OK.

    How to Find the PATH Variable

    Under the Environment Variables window, choose or highlight the PATH variable in the System Variables section shown in the window.

    After highlighting the PATH variable from System Variables, click the Edit button.

    You can add or modify the path lines with the directories you want your computer to look in for executable files. You will find that each different directory is separated with a semicolon, for example:

    There are other environment variables in the System Variables section that you can examine by clicking Edit.

    Likewise, there are different environment variables, such as PATH, HOME and USER PROFILE, HOME and APP DATA, TERM, PS1, MAIL, TEMP, and so on. These Windows environment variables are very useful and can be used in scripts as well as on the command line.

    Speaking of the command line, you can test your changes by opening a new PowerShell window and entering the following:
    $env:PATH

    Frequently Asked Questions

    Here is some more information about Environment Variables for you:

    How Do I Find Environment Variables in Windows 10?

    To find environment variables in Windows 10, you can follow the steps described above to find the environment variable information tucked away inside the system’s advanced settings.

    Alternatively, if you just need to see what the variables are but don’t need to change them, you can simply open a command-line interface by hitting Ctrl-Esc and typing “cmd” in the command box, then type “set” in the command window. This prints out all the environment variables that are set on your system.

    Why can’t I edit the Environment Variables?

    There are several reasons that you may not be able to set these variables. The first of your problems could be that you don’t have Admin rights. To set or edit this function, you must be the Administrator of the system.

    If you are the Admin, yet the edit function is greyed out, try accessing the Environment Variables by accessing the Control Panel from the Start menu. Click on ‘Advanced System Settings,’ then click ‘Environment Variables.’

    Final Thoughts

    Windows 10 environment variables make it incredibly easy to take control of your Windows device and make it run more efficiently.

    To find and set environment variables in Windows 10, follow the simple steps laid out in this article to get started.

  • Оцените статью