Choose the long path (or goodbye MAX_PATH). Final path setup


The path to a specified file consists of one or more components separated by a special character (backslash), with each component typically being a directory name or file name, but with some notable exceptions described below. This often has crucial to interpret the path system: what the beginning or prefix of the path looks like. This prefix specifies the namespace that the path uses and, in addition, what special characters are used at what position in the path, including the last character.

If the path component is a filename, it must be the last component.

Each path component will also be limited by the maximum length specified for the specific file system. In general, these rules fall into two categories: short and long. Note that directory names are stored in the file system as special type file, but the naming rules for files also apply to directory names. So a path is simply a string representation of the hierarchy between all the directories that exist for a particular file or directory name.

Full and relative paths

For Windows API functions that manipulate files, file names can often be relative to the current directory, while some APIs require the full path. The file name refers to the current directory unless it begins with the following:

  • A UNC name of any format that always begins with two backslash characters ("\\").
  • A drive designator followed by a backslash, such as "C:\" or "d:\".
  • A single backslash, such as "directory\" or "\file.txt" This is also called an absolute path.
If a filename begins only with a drive pointer, but not with a backslash after a colon, it is interpreted as a relative path to the current directory on the specified drive letter. Note that the current directory may or may not be the root directory depending on what it was set to at the time last operation"change directory" on this drive. Examples of this format look like this:
  • "C:tmp.txt" refers to a file named "tmp.txt" in the current directory on the C drive.
  • "C:tempdir\tmp.txt" refers to a file in a subdirectory of the current directory on the C drive.
A path is also considered relative if it contains "two points"; that is, two periods together in one path component. This special qualifier is used to designate the directory above the current directory, otherwise known as the "parent directory". Examples of this format look like this:
  • "..\tmp.txt" points to a file named tmp.txt, which is located in the parent directory of the current directory.
  • "..\..\tmp.txt" points to a file that is located two directories above the current directory.
  • "..\tempdir\tmp.txt" specifies a file named tmp.txt that is located in a directory named tempdir in the same directory of the current directory.
Relative paths can combine both types of examples, for example "C:..\tmp.txt". This is useful because although the system keeps track of the current drive along with that drive's current directory, it also keeps track of the current directories in each different letters drive (if your system has more than one), regardless of which drive is designated as the current drive.

Maximum path length limit

In the Windows API (with some exceptions that will be discussed in the following paragraphs), there is a maximum path length in max_path that is defined as 260 characters. The local path is structured in the following order: drive letter, colon, backslash, name components separated by backslashes, and a terminating null character. For example, the maximum path to drive D is "D:\some 256-character path string ", where " " represents an invisible NULL character for the current system code page. (The characters are used here for clarity and cannot be part of a valid path string.)

The file I/O functions in the Windows API convert "/" to "\" as part of the name conversion to an NT type name, unless the "\\?\" prefix is ​​used.

There are many functions in the Windows API that also have Unicode versions to allow extended path lengths for a maximum total path length of 32,767 characters. This path type consists of components separated by backslashes, each up to the value returned in the Lpmaximumcomponentlength parameter of the GetVolumeInformation function (this value is typically 255 characters). To specify an extended length path, use the "\\?\" prefix. For example?\\" ?\D:\very_long_path".

Note that the maximum path of 32,767 characters is approximate because the "\\?\" prefix can be expanded to a longer string by the system at runtime, and this expansion is applied to the total length.

This same prefix can also be used with paths built according to the Universal Naming Convention (UNC). To specify such a path using UNC, use "\\?\UNC\". For example?\\",\UNC path\\server\share", where "server" is the name of the computer and "share" is the name of the shared folder. These prefixes are not used as part of the path itself. They indicate that the path must be passed to the system with minimal modification, meaning that you cannot use forward slashes to represent path separators, or a dot to represent the current directory, or double dots to represent the parent directory. Since you cannot use the "\\?\" prefix with a relative path, relative paths are always limited to a total of MAX_PATH characters.

There is no need to do anything to normalize the Unicode in the path and filename strings for the Windows file I/O API functions, because the file system treats the path and filenames as a sequence of wchar values. Any normalizations required by your application should be done with this in mind, external to any calls made to the file Windows functions I/O API.

When using the API to create a directory, the specified path cannot be so long that the 8.3 filename cannot be added (that is, the directory name cannot exceed MAX_PATH minus 12).

The shell and the file system have different requirements. You can create a path with Windows API, which the shell user interface is unable to interpret properly.

Starting with Windows 10 version 1607, MAX_PATH restrictions have been removed from shared Win32 file and feature directories. However, it is necessary to choose a new behavior. The registry allows you to enable or disable the new long path behavior. To enable long paths, set the registry key to

HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled (Type: reg_dword). The key value will be cached by the system (per process) after the first call to a Win32 file or directory function. The registry key will not be reloaded for the life of the process. A reboot may be required for all applications on the system to recognize the key's value because some processes may have started before the key was set.

You can also enable the new long path behavior on a per-app basis via the manifest:

true These are the directory management functions that will not have a max_path limit if you enable long paths: CreateDirectoryW, CreateDirectoryExW GetCurrentDirectoryW RemoveDirectoryW SetCurrentDirectoryW.

Good afternoon, dear readers and guests of the blog, today I want to discuss with you this topic: what are Windows environment variables, where can they be used, both in normal user practice and in the practice of a system administrator, I will give you a few examples. How this whole thing is configured and changed to suit your needs, in my opinion, this is fundamental knowledge, the understanding of which will better show you the principle of operation of operating systems of the Windows family.

What are windows environment variables

Let's understand the concept, and so environment variable (environment variable) these are a special kind of links of reduced size to certain objects of the Windows operating system, used by different programs to store information and interact with it. An analogy can be drawn with relative links on sites where there is no explicit indication of the protocol. Most often these are paths to specific directories in the OS.

Where are Windows environment variables used?

Let me give you a few examples:

  • In scripts > when, for example, each user needs to make some kind of setting, for example, put a new folder with documents on the desktop. Since each user has their own path to the desktop, like C:\Users\lacky\Desktop, and you can also access the relative path using the %HOMEPATH% variable, if you enter %HOMEPATH%\Desktop in Explorer, you will be taken to the desktop current user's table.

  • V group policy, for setting up user environments, such as roaming profiles.
  • Code optimization > If your code very often uses the same file or folder paths, as well as registry keys, you can easily assign a short variable for further use. Below I will give you a summary list of environment variables windows 10 and previous versions, and will also show you how to create and change them.

All environment variables of Windows 10 and other versions include special operator%. It is necessary so that the operating system can process the search request. A simple example: you are looking for the TEMP folder and don’t know where it is located, enter %TEMP% and the search will be on all local disks and sections.

List of Windows 10 environment variables

The given list, in to the fullest Suitable for both Windows 7 and Windows 8.1, everything has been personally tested. I am sure that this knowledge will greatly help you optimize your work.

  • %ALLUSERSPROFILE% > this variable will send you to the C:\ProgramData folder
  • %windir% > this is the C:\Windows folder
  • %APPDATA% > you are caught in hidden folder C:\Users\Username\AppData\Roaming
  • %CommonProgramFiles% > folder C:\Program Files\Common Files
  • %CommonProgramFiles(x86)% > will take you to C:\Program Files (x86)\Common Files
  • %CommonProgramW6432% > will redirect you to C:\Program Files\Common Files
  • %COMPUTERNAME% > Computer_name, used in scripts
  • %ComSpec% > will open Windows 10 Command Prompt C:\Windows\system32\cmd.exe
  • %HOMEDRIVE% > path to drive C:
  • %HOMEPATH% > this windows environment variable will take you to the user folder \Users\Username
  • %LOCALAPPDATA% > this windows environment variable will take you to the folder C:\Users\Username\AppData\Local
  • %LOGONSERVER% > ComputerName
  • %NUMBER_OF_PROCESSORS% > Number_of_processors
  • %OS% > Windows_NT, also used in scripts
  • %Path% > C:\Windows\system32;C:\Windows;C:\Windows\System32Wbem;
  • %PATHEXT% .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
  • %PROCESSOR_ARCHITECTURE% > x86 or AMD64, Windows architecture
  • %PROCESSOR_IDENTIFIER% > Intel64 Family 6 Model 37 Stepping 5, GenuineIntel
  • %PROCESSOR_LEVEL% > 6
  • %PROCESSOR_REVISION% > 2505 (example)
  • %ProgramData% > folder C:\ProgramData
  • %ProgramFiles% > C:\Program Files
  • %ProgramFiles(x86)% > folder C:\Program Files (x86)
  • %ProgramW6432% > C:\Program Files
  • %PROMPT% > $P$G
  • %PSModulePath% > C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ agree very quickly
  • %PUBLIC% > C:\Users\Public
  • %SystemDrive% > drive C:
  • %SystemRoot% > C:\Windows
  • %TEMP% >
  • %TMP% > C:\Users\Username\AppData\Local\Temp (default)
  • %USERDOMAIN% > ComputerName
  • %USERDOMAIN_ROAMINGPROFILE% > ComputerName
  • %USERNAME% > Username
  • %USERPROFILE% > C:\Users\Username

How to list all Windows variables

In Windows 10 and other versions, you can display a list of all Windows environment variables by opening a command prompt as an administrator and entering the SET command. As a result, you will get all the default Windows 10 environment variables for a specific operating system.

For convenience, you can export this entire list to a text file, to do this, enter:

set > D:\Variables.txt

Here are the contents of this document.

Another method to view operating system variables is Windows registry. Press WIN+R and enter regedit. In the Registry Editor window that opens, go to the branch:

To view variables for the computer

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

To view variables for a user

HKEY_CURRENT_USER\Environment

Create Windows 10 environment variables

In addition to existing Windows 10 variables, you can create new ones, this is very easy and is not prohibited. What is required of you, you need to go to the system properties. There are several methods, if we are talking about Windows 10, then you can do it by right-clicking on the “Start” button, selecting System.

A universal method is to go to the properties of my computer or click keyboard shortcut WIN+Pause Break.

From the system properties window, you should go to "Advanced system settings"

And here are two types of Windows environment variables:

  • Temporary variables temp
  • System Variables

Both can be easily modified or created.

For example, I will create a new system variable, call it SYSPREP and specify the path to the folder C:\Windows\System32\Sysprep

As you can see, there is nothing complicated here; thanks to things like this, you can greatly simplify your life and save a lot of time.

This section concerns:
  • Platforms: Solaris SPARC, Red Hat Linux, SUSE Linux, Oracle Linux, Windows 10, Windows 8, Windows 7, Vista, Windows XP, Mac OS X

The instructions on this page are intended only for experienced users and system administrators.


General information

  • Variable PATH is a system variable that the operating system uses to find the desired executable objects on the command line or terminal window.
  • System variable PATH can be set using system utility in the Windows Control Panel or using the Linux and Solaris shell startup file.
  • On computers running Windows or Mac OS X making changes to the PATH system variable usually not required.

Windows

Windows 10 and Windows 8
  1. In the "Search" line, search for: System (Control Panel)
  2. Click on the link.
  3. Click Environment Variables. In the section Environment Variables Change
  4. In the window (or New system variable OK OK.
Windows 7
  1. On the desktop, right-click on the icon Computer.
  2. IN context menu select Properties.
  3. Click on the link Advanced System Settings.
  4. Click Environment Variables. In the section Environment Variables select the PATH environment variable. Click Change. If the PATH variable does not exist, click Create.
  5. In the window Changing a system variable(or New system variable) specify the value of the PATH environment variable. Click OK. Close the rest open windows, pressing OK.
  6. Reopen the command prompt window and run the java code.
Windows XP
  1. Click Start, select Control Panel, double click on System and select a tab Additionally.
  2. Click Environment Variables. In the section Environment Variables select the PATH environment variable. Click Change. If the PATH variable does not exist, click Create.
  3. In the window Changing a system variable(or New system variable) specify the value of the PATH environment variable. Click OK. Close other open windows by clicking OK.
  4. Reopen the command prompt window and run the java code.

Mac OS X

To run a different version of Java, specify full path or use the java_home tool:

% /usr/libexec/java_home -v 1.8.0_73 --exec javac -version

Solaris and Linux

  1. To see if the path is configured correctly:
    In terminal windows, enter:
    % java -version
    The version of the java tool will be displayed if it cannot be found. If the version is outdated or an error appears java: command not found, then the path is set incorrectly.
  2. Determine which executable version of java is the first one found in a variable PATH
    In a terminal window, enter:
    % which java
Final path setup

To set the path permanently, configure it in the startup file.
Note. Instructions are provided for the two most popular shells on Linux and Solaris. If you are using other shells, see the tutorial on setting the PATH variable.

Bash shell

Edit the startup file (~/.bashrc)

  1. Change a variable PATH variable
    PATH=/usr/local/jdk1.8.0/bin:$PATH
    export PATH
  2. Download the startup file
    %. /.profile

  3. % java -version
C shell (csh)

Edit the startup file (~/.cshrc)

  1. Set the path
    set path=(/usr/local/jdk1.8.0/bin $path)
  2. Save changes and close window
  3. Download the startup file
    % source ~/.cshrc
  4. Make sure the path is set by repeating the java command
    % java -version

Folder "AppData" contains user information of various applications (history, settings, sessions, bookmarks, temporary files, etc.). Over time, it becomes clogged with various data that may no longer be needed, but only takes up disk space. In this case, it makes sense to clean out this directory. In addition, if, when reinstalling the operating system, the user wants to retain the settings and data that he used in various programs earlier, you need to transfer the contents of this directory from the old system to the new one by copying it. But first you need to find where it is located. Let's find out how to do this on computers with operating system Windows 7.

Name "AppData" stands for “Application Data”, that is, translated into Russian means “application data”. Actually, in Windows XP this directory had its full name, which in later versions was shortened to its current name. As mentioned above, this folder contains data that accumulates during the operation of application programs, games and other applications. There may be more than one directory with this name on your computer, but several. Each of them corresponds to a separate created user account. In the catalog "AppData" There are three subdirectories:

  • "Local";
  • "LocalLow";
  • "Roaming".

Each of these subdirectories contains folders whose names are identical to the names of the corresponding applications. These directories should be cleaned to free up disk space.

Enable visibility of hidden folders

You should know that the directory "AppData» hidden by default. This is done to prevent inexperienced users from mistakenly deleting important data contained in it or its entirety. But in order to find this folder, we need to turn on visibility hidden folders. Before moving on to detection methods "AppData", let's find out how to do this. There are several options for enabling the visibility of hidden folders and files. Those users who want to familiarize themselves with them can do so using a separate article on our website. Here we will consider only one option.


Showing hidden folders will be enabled.

Method 1: Search programs and files field

Now let's move directly to the ways in which you can move to the desired directory or find where it is located. If you need to go to "AppData" current user, then this can be done using the field "Find programs and files", which is located in the menu "Start".


Directly to the catalog "AppData" you can get there directly by entering an expression in the field "Find programs and files".


Method 2: Run Tool

A very similar algorithm for opening a directory "AppData" can be done using the system tool "Run". This method, like the previous one, is suitable for opening a folder for the account under which the user is currently working.


Similarly with the previous method, you can immediately get to the folder "AppData".


Method 3: Go through Explorer

How to find out the address and get into the folder "AppData", intended for the account in which the user is currently working, we figured it out. But what if you need to open a directory "AppData" for another profile? To do this, you need to make the transition directly through "Conductor" or enter the exact location address, if you already know it, in the address bar "Conductor". The problem is that for each individual user, depending on the system settings, the location of Windows and the names of the accounts, this path will be different. But the general pattern of the path to the directory where the desired folder is located will look like this:

(system_drive):\Users\(user_name)


There are several options to get into the folder "AppData" and find out its location in Windows 7. This can be done as a direct transition method using "Conductor", and by introducing command expressions into the fields of some system tools. It is important to know that there may be several folders with a similar name, in accordance with the names of the accounts that are created in the system. Therefore, you need to immediately understand which directory you want to go to.