Quickly change directory to desktop
I got used to start the commandline with elevated permissions. Unlike the start as a normal user, you do not end up in the user directory %userprofile% - from where you only need to type "cd desktop" and hit enter - but in the system path %systemroot%\system32, from where it's not possible to reach the desktop without typing a longer path. If you turned off the UAC, you also will end up in system32, even if you startet cmd as normal user.
At first, i thought a solution with mklink could do the trick. But it turned out, that its not practicable for directories which are user dependent and the installed Windows language is also an obstacle. It's also possible, but rare, that someone has changed the path of it's own desktop.
Another solution is, to simply edit the start-parameter of the cmd shortcut in the startmenue. But, as in my case, only the cmd.exe shows off, because i've installed a 3rd party startmenue, from which the cache got broke. All i want say, this could happen to anyone. Furthermore, i always execute it with the keyboard shortcut WIN + R, means, i always start the cmd.exe directly.
The all in one solution - in my opinion - is to create a batch file called "desktop.bat" in system32 - from where every default Windows command gets started - which will automatically search in the current logged on user-registry for its absolute desktop path, save it in a variable and executes cd variable. From this point of, you would only have to type "desktop" and hit enter and you will be in your own desktop directory. No matter which path you are in at the moment.
That is what it looks like:
@echo off FOR /F "usebackq tokens=3 " %%i in (`REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) DO SET desktopdir=%%i FOR /F "usebackq delims=" %%i in (`ECHO %desktopdir%`) DO SET desktopdir=%%i cd %desktopdir% cls