Note: This answer was discovered through conversation in the question's comments.
The location of the Desktop folder in most versions of Windows is %USERPROFILE%\Desktop
, which for most users becomes C:\Users\YOURUSERNAME\Desktop
.
However, this location can also be changed by programs installed on your computer and is a common feature amongst workspace-switching/multi-desktop utilities.
In later editions of Windows in particular, OneDrive is installed as part of the operating system and as part of initial setup, it will ask you if you wish to backup your documents, pictures and desktop to your OneDrive account. This will allow you to have the same files available on each Windows computer you use that where you log into OneDrive.
If you choose to backup your Desktop with OneDrive, your desktop will silently be moved to %USERPROFILE%\OneDrive\Desktop
instead of the default. The %USERPROFILE%\Desktop
will still exist in it's original location, but will no longer contain your desktop files.
Because the original Desktop folder exists, using cd Desktop
after opening command prompt will still work, but as it contains no files or folders, using cd SomeFolderOnTheDesktop
will lead to the The system cannot find the specified path error.
The Solutions
1. "Open command window here"
In older versions of Windows, you can open any folder in Explorer, hold down the Shift
key, right-click the background of the open folder and then select "Open command window here". Since Windows 10, this has been replaced with "Open Powershell window here". However you can bring back "Open command window here" manually by following this WindowsCentral guide.
2. Use a directory junction to link your the system Desktop folder to the OneDrive Desktop folder.
Open the Run dialog (Windows Key + R), then type in %USERPROFILE% and press Enter. This will open your User Profile directory (C:\Users\YOURUSERNAME
). Rename the existing Desktop folder to something like "Desktop-old". Then go into the OneDrive folder, right-click the Desktop folder there, and then select "Always keep on this device". If your internet goes out, your Desktop files will still be available and not cause future head-scratching when you can't open them or they take a long time to open.
Open the Command Prompt, and then execute the following command:
mklink /J "%USERPROFILE%\Desktop" "%USERPROFILE%\OneDrive\Desktop"
Now whenever you open %USERPROFILE%\Desktop
(in any program) you'll actually be looking at the contents of %USERPROFILE%\OneDrive\Desktop
. So cd Desktop
and then cd SomeFolderOnTheDesktop
will work as expected.
Disclaimer: Care must be taken when working with files in %USERPROFILE%\Desktop
with this method, as there may be unintended bugs with OneDrive's sync features. I haven't had any issues, but the warning is there none-the-less.
3. Disable OneDrive's Desktop backup
Note: Backups are a good idea. Avoid if possible.
Right-click the OneDrive icon in the system tray and select Settings. In the new window, change to the "Back up" tab, and then click "Manage backup". Work through the setup wizard to reconfigure your settings.