3

Is there any shortcut for desktop in windows command prompt ? (like %WINDIR% for windows directory)
I want to use cd %DESKTOP% for example.

LotPings
  • 7,231

1 Answers1

7

Closest thing to that (without you setting your own Variable) is

cd %UserProfile%\Desktop

Beyond that you can set your own Variable:

SET DESKTOP=%USERPROFILE%\Desktop

And then cd %Desktop% will bring you to x:\Users\YourUserName\Desktop

For Command Line options to do the same:
setx desktop "%userprofile%\desktop" for User Variable
setx desktop "%userprofile%\desktop" /M for Computer/System-wide Variable

Darius
  • 5,394
  • Thanks... but SET DESKTOP=%USERPROFILE%\Desktop not work in another session. right ? – Mohsen Zia May 07 '18 at 05:57
  • If you want to set it as a permanent thing for your whole User Session--> Control Panel - System - Advanced System Settings --> Environment Variables. You will see 2 box, the top one is for "You" as the logged in user, The bottom one is for 'the whole system' (anyone logged in to the PC). Just set it on the top one as a "new" variable and it will persist. You can also set it to the bottom one. Since you are using the variable %UserProfile% it will dynamically be the person logged in. If you prefer Command Line option it is setx desktop "%userprofile%\Desktop" – Darius May 07 '18 at 05:59
  • Unfortunately it won't work if user has relocated the desktop to another place – Ubeogesh Nov 10 '21 at 12:06