16

This has bothered me for ages, and I could not find the solution yet.

  1. Open Windows Explorer.
  2. Click on Desktop in the left sidebar.
  3. Click on "Desktop" in the address bar.

Result: Instead of C:\...\ it displays only Desktop.

Desktop Windows Explorer

Instead I would like to get the real physical path:

C:\Users\MyName\Desktop\

How can I achieve this (settings in the Windows registry)?

Avatar
  • 2,844

10 Answers10

10

It's not possible to change this particular aspect of Windows' behaviour from the GUI but there is a nice workaround that doesn't require any third-party software:

  1. Open Windows Explorer: Windows + E.

  2. While holding Shift, perform a Right click ️ on the Desktop folder, then choose Copy as path from the context menu:

    screenshot

The full path of your Desktop folder is now copied to the clipboard and can be pasted into the address bar or wherever you require it.

Note that the path will include quotation marks that you'll need to remove in order for it to work properly in Windows Explorer.

This should give you something like this:

"C:\Users\MyName\Desktop"
Avatar
  • 2,844
Mr Ethernet
  • 4,459
9

%UserProfile%\Desktop is wrong!!! Never use it

Special folders can be moved around easily, that's why there are registry entries for them, otherwise we'd just need to hard code them everywhere. Even Windows could be installed into a different folder/drive than C:\Windows and Program Files can be changed. Same to Documents, Pictures, Desktops... Nowadays Windows tend to enable OneDrive backup by default and user special folders will not be in the user's home path anymore. And even the OneDrive folder path can be changed

Desktop properties

See %USERPROFILE%/Desktop no longer valid after relocating Desktop folder to OneDrive

To get the path reliably you'll need to call this by running the below command in PowerShell

[Environment]::GetFolderPath([Environment+SpecialFolder]::Desktop)

Alternatively you can run this in PowerShell

(New-Object –ComObject Shell.Application).namespace(0x10).Self.Path

0x10 here is the Shell Special Folder Constant for desktop

Another PowerShell way:

$c = New-Object -ComObject Wscript.Shell
$c.SpecialFolders("Desktop")

The above last 2 solutions deal with COM objects so they can be written in pure VBS or Js, or even hybrid batch-VBS/Js. For example pure VBS solution of the above:

Set oShell = CreateObject("Wscript.Shell")
Set oSFolders = oShell.SpecialFolders
WScript.Echo oSFolders("Desktop")

Hybrid batch/Js solution of the second snippet

@if (@CodeSection == @Batch) @then
@echo off
cscript //e:jscript //nologo "%~f0" %*
exit /b
@end

// JScript Section WScript.Echo((new ActiveXObject("shell.application")).namespace(0x10).Self.Path);

From a batch file you can call PowerShell to get the path if you don't want the hybrid solution above

powershell -C "[Environment]::GetFolderPath([Environment+SpecialFolder]::Desktop)"

The "pure" batch solution is much trickier because you'll have to parse multiple registry keys

@echo off
setlocal EnableExtensions DisableDelayedExpansion

set "DesktopFolder=" for /F "skip=1 tokens=1,2" %%I in ('%SystemRoot%\System32\reg.exe QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop 2^>nul') do if /I "%%I" == "Desktop" if not "%%~K" == "" if "%%J" == "REG_SZ" (set "DesktopFolder=%%~K") else if "%%J" == "REG_EXPAND_SZ" call set "DesktopFolder=%%~K" if not defined DesktopFolder for /F "skip=1 tokens=1,2" %%I in ('%SystemRoot%\System32\reg.exe QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v Desktop 2^>nul') do if /I "%%I" == "Desktop" if not "%%~K" == "" if "%%J" == "REG_SZ" (set "DesktopFolder=%%~K") else if "%%J" == "REG_EXPAND_SZ" call set "DesktopFolder=%%~K" if not defined DesktopFolder set "DesktopFolder=" if "%DesktopFolder:~-1%" == "" set "DesktopFolder=%DesktopFolder:~0,-1%" if not defined DesktopFolder set "DesktopFolder=%UserProfile%\Desktop"

echo Desktop folder is: "%DesktopFolder%"

endlocal

phuclv
  • 30,396
  • 15
  • 136
  • 260
2
  1. Copy the following code and save it in a .reg file.

    shell_folder_full_path.reg

    Windows Registry Editor Version 5.00
    

    ;Desktop [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}] "ParsingName"=-

    ;Local Documents [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{f42ee2d3-909f-4907-8871-4c22fc0bf756}] "ParsingName"=-

    ;Local Downloads [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{7d83ee9b-2244-4e70-b1f5-5393042af1e4}] "ParsingName"=-

    ;Local Music [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{a0c69a99-21c8-4671-8703-7934162fcf1d}] "ParsingName"=-

    ;Local Pictures [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{0ddd015d-b06c-45d5-8c4c-f59713854639}] "ParsingName"=-

    ;Local Videos [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions{35286a68-3c57-41a1-bbb1-0eae73d76c95}] "ParsingName"=-

  2. Run that .reg with Administrator Right.

  3. Restart Explorer.exe

Source: WinHelpOnline

Important: Note that the above workaround doesn’t help if:

  • You’ve redirected the shell folder(s) to OneDrive
  • You’re accessing the shell folder via This PC instead of Quick access
phuclv
  • 30,396
  • 15
  • 136
  • 260
Rexpert
  • 29
1

You can use this method to get the path to the desktop.

  1. right-click on the desktop file
  2. properties
  3. location

Then you can copy the path.

The screenshot explains the steps:

Image

0

It's hard to battle the Shell namespace. As a workaround, the following .reg file will add a context menu item to open the file system folder corresponding to a shell folder.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenFSFolder]
@="Open file folder (new window)"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenFSFolder\command]
@="explorer.exe \"%V\""

[HKEY_CLASSES_ROOT\Directory\shell\OpenFSFolder]
@="Open file folder (new window)"

[HKEY_CLASSES_ROOT\Directory\shell\OpenFSFolder\command]
@="explorer.exe \"%V\""

Keith Miller
  • 10,694
  • 1
  • 20
  • 35
0

Using %UserProfile%\Desktop reveals the Desktop path.

So I solved it with this AutoHotkey script:

; Save Dialog: hitting CTRL D opens desktop
^d::
    ControlFocus, DirectUIHWND2, A
    SendInput, % "!d%userprofile%\Desktop{enter}!n"
return

Or:

; Windows explorer, hitting Ctrl + D goes to the address bar and shows the full desktop path
#IfWinActive ahk_class CabinetWClass
    ^D::
        Send !D
        String := "%UserProfile%\Desktop"
        SendRaw %String%
        Send {ENTER}
        Send !D
    return
#IfWinActive

Hitting Ctrl + D does focus the address bar now and reveals the path.

Finally, one Windows problem less .

Avatar
  • 2,844
-2

You can right-click and select Property on the folder name, copy the parent path, and then add the name of folder you want to access.

Example

-2

After getting a new machine, I realize that in the explorer, I have a Desktop treeview item, in that I have a User treeview item, and inside the user treeview item, another treeview item that is called Desktop.

(I translated everything to English, maybe more simple to understand.)

In the first Desktop item, I have 33 entries. In the second one I have 9 entries.

All the methods that have been given here (I did not try via the register) give the path of the second Desktop item.

I should like to browse the first one in a winforms program, that does not appear simple.

For both items, the "Command line" item of the context menu opens to "C:\Users\User\Desktop".

The Properties command of the first one sends to the Parameters application of Windows. The Properties command of the second Desktop item gives a properties dialog box, with path "C:\Users\User\Desktop".

N.B. On this machine I did not access OneDrive yet. No trace of the desktop in the environment.

Maybe this helps to understand some of the difficulties met, and helps (or will help) to be more precise in the expression.

-3

To access the "hidden" (screen) desktop in Windows 10:
Double-click on "This PC".
Click on the "UP" arrow (up one directory level).

This will show all items on the primary desktop screen.

Tim
  • 1
-4

The two desktops are the user desktop, and the public desktop.

Perhaps I should look in the APIs how to know the paths of both, but in a rather common configuration they are

C:\users\username\desktop
C:\users\public\desktop

In some contexts the user desktop is hosted elsewhere, for instance on OneDrive.