Obtain desktop path with batch

I havn't tested this in Windows 8 yet.

    @echo off
    call :GetDesktop
    echo desktop path = %desktop%
    goto :EOF


    :GetDesktop
    reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop | find "Desktop" > o.txt
    for /F "tokens=2 delims=\" %%a in (o.txt) do set "desktop=%userprofile%\%%a"
    del o.txt
    goto :EOF