I have a batch script that need the full path of the Desktop folder.
Right now I am using %USERPROFILE%/Desktop
, it works fine until I learned that the path can be changed (See Can you change the location of the Desktop folder in Windows?).
I tried to read the regedit and I end up with something like this (I have cygwin installed):
REG QUERY "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\Current
Version\Explorer\Shell Folders" /v Desktop |grep Desktop| awk '{$1=$2=""; print $0}'
This is working fine but I don't like it for the sake of robust and simplicity. Not to metion that it will be even more messy if I don't have awk
avaliable.
As I noticed, you can type shell:Desktop
in File Explorer and it will open the Desktop folder for you. However I have no clue how I can use that in a batch file.
Is there a hidden environment variable or simple command I can use to retrive this value?