WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Max Path in WinBatch


Question:

What is the WinBatch max file name size and file path size?

Answer:

In the Windows API, the constant MAX_PATH is defined to be 260 characters. The definition of path includes drive letter, colon, backslash, components separated by backslashes, and a NULL terminator. Likewise, UNC paths that replace the drive letter & colon with 2 backslashes, a server name, a backslash and a share name can also be used, but with the same 260 character restriction.

Certain Unicode versions of Win32 API functions can use significantly longer paths, upwards of 32,000 characters, provided that you apply the prefix "\\?\" in front of the remainder of the path [e.g. "\\?\D:\SomeReallyAwfullyLongFolderName\Followed \By\SomeOtherFolder\And\SomeFileName.txt"]... you get the picture. Likewise, for UNC paths, the long form of the Unicode path would be "\\?\UNC\\" followed by the remainder of the UNC path.

There are limitations to when, where & how this notation can be used. No forward slashes can be used... you must use backslashes. Likewise, no relative paths can be used, so no "." representations of directories are permitted. All relative path values are limited to MAX_PATH characters.

This long format notation causes the path to be passed to the underlying system routines with minimal parsing and/or modification.

What I don't have handy is a complete list of I/O related API functions that support this notation, nor do I have any correlation between WIL functions and these API functions to know for ceratin whether or not it's safe to use this notation from within a WinBatch script.

For more see:
Naming Files, Paths, and Namespaces (Windows)


Article ID:   W17977
Filename:   Max Path in WinBatch.txt
File Created: 2012:12:20:11:51:58
Last Updated: 2012:12:20:11:51:58