On Windows 10, I have created the following folder:
C:\BigLongFolderName
If I run the following test.bat from Windows Explorer with "Run as Administrator" on the right-click context menu from within the above folder, I get a shortened 8.3 folder name.
test.bat
echo "%~dp0"
echo %~dp0
Output:
C:\windows\system32>echo "C:\BIGLON~1\"
"C:\BIGLON~1\"
C:\windows\system32>echo C:\BIGLON~1\
C:\BIGLON~1\
How do I get the long folder name in Windows 10 when using "Run as Administrator"?
The output I want to see is C:\BigLongFolderName\
I do literally have a folder called C:\BigLongFolderName on my machine.
If I run the same test.bat by double-clicking on it (instead of "Run as Administrator") then I am echoed the full C:\BigLongFolderName
path as I would expect. Why does "Run as Administrator" not give me the long path?
I moved this question from Stackoverflow as "its not a programming question".
The following post suggests that I should be getting long name format by default and indeed my 2 of my collegues do:
https://stackoverflow.com/questions/15567809/batch-extract-path-and-filename-from-a-variable
Please note that I not want to convert 8.3 names into long names. I want the long names to be returned sames as other people are getting.
pause
in thetest.bat
, you'll see a black screen disappear very quickly. Not quickly enough for you to copy and paste your result. I usedpause
and gotC:\BigLongFolderName
twice. I also ran this incmd.exe
and got the same result. HOWEVER, if you run this fromcommand.com
you will get the short names (command.com
is the old 16-bit command line for DOS programs). (note the difference incmd.exe
andcommand.com
)C:\BIGLON~1
you'll always get the short 8.3 folder name.