Apparently, Windows (or at least some part of Windows) ignores multiple backslashes in a path and treats them as a single backslash. For example, executing any of these commands from a command prompt or the Run window opens Notepad:
C:WindowsSystem32Notepad.exe
C:WindowsSystem32\Notepad.exe
C:WindowsSystem32\Notepad.exe
C:WindowsSystem32\\Notepad.exe
C:\Windows\System32\Notepad.exe
C:\Windows\System32\Notepad.exe
This can even work with arguments passed on the command line:
notepad "C:UsersusernameDesktop\\myfile.txt"
Is this behavior documented anywhere? I tried several searches, and only found this SO question that even mentions the behavior.
Note: I am not asking about UNC paths (\servername), the \? prefix, or the " double-quote escape.
Note: I stumbled upon this behavior while working with a batch file. One line in the batch file looked something like this:
"%SOME_PATH%myapp.exe"
After variable expansion, the command looked like:
"C:Program FilesVendorMyApp\myapp.exe"
To my surprise, the batch file executed as desired and did not fail with some kind of "path not found" error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…