Friday, January 15, 2016

Creating Permanent All-User Network Drives with \\?\UNC\

A little-known detail of Windows is that prepending \\?\ to a path makes Windows internals treat it as a literal path, allowing it to exceed the normal limit of 260 characters. A special case of the notation is that \\?\UNC\ indicates a network path. For example,

\\?\UNC\server\share

points to a share called share on server. This fact makes it possible to create network drive mappings that apply to all users with the help of the key called:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices

Entries in that key function as DOS-style magic file names, but they can also be used to map network drives. For example, an entry called Z: with the previously-mentioned path as its value would create a network drive lettered Z for all users.

Interesting note: there's advice going around on the Internet that you need two question marks for this to work. That's false - it works just fine with only one, and question marks don't need to be escaped in the Registry or in file paths.

No comments:

Post a Comment