Last active
August 29, 2016 07:43
-
-
Save mrchnk/a014ff78134e1bdd02971e81e5cc2f2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal | |
| set "Reg32=%SystemRoot%\System32\reg.exe" | |
| if not "%ProgramFiles(x86)%"=="" "Reg32=%SystemRoot%\SysWOW64\reg.exe" | |
| for /F "usebackq skip=1 tokens=1,2*" %%T in (`%Reg32% query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{374DE290-123F-4565-9164-39C4925E467B}" 2^>nul`) do ( | |
| if /I "%%T"=="{374DE290-123F-4565-9164-39C4925E467B}" ( | |
| set "DownloadShellFolder=%%V" | |
| goto GetDownloadDirectory | |
| ) | |
| ) | |
| :GetDownloadDirectory | |
| for /F "usebackq skip=1 tokens=1,2,3*" %%S in (`%Reg32% query "HKCU\Software\Microsoft\Internet Explorer" /v "Download Directory" 2^>nul`) do ( | |
| if /I "%%S"=="Download" ( | |
| if /I "%%T"=="Directory" ( | |
| set "DownloadDirectory=%%V" | |
| goto GetSaveDirectory | |
| ) | |
| ) | |
| ) | |
| :GetSaveDirectory | |
| for /F "usebackq skip=1 tokens=1,2,3*" %%S in (`%Reg32% query "HKCU\Software\Microsoft\Internet Explorer\Main" /v "Save Directory" 2^>nul`) do ( | |
| if /I "%%S"=="Save" ( | |
| if /I "%%T"=="Directory" ( | |
| set "SaveDirectory=%%V" | |
| goto OutputResults | |
| ) | |
| ) | |
| ) | |
| :OutputResults | |
| cls | |
| echo. | |
| if not exist "%USERPROFILE%\Downloads" goto OutputShellFolder | |
| echo Download directory of user account is: | |
| echo. | |
| echo %USERPROFILE%\Downloads | |
| echo. | |
| echo. | |
| :OutputShellFolder | |
| if "%DownloadShellFolder%"=="" goto OutputDownloadDir | |
| if "%DownloadShellFolder:~-1%"=="\" set "DownloadShellFolder=%DownloadShellFolder:~0,-1%" | |
| echo Download shell folder of user account is: | |
| echo. | |
| echo %DownloadShellFolder% | |
| echo. | |
| echo. | |
| :OutputDownloadDir | |
| if "%DownloadDirectory%"=="" goto OutputSaveDir | |
| if "%DownloadDirectory:~-1%"=="\" set "DownloadDirectory=%DownloadDirectory:~0,-1%" | |
| echo Download directory of Internet Explorer is: | |
| echo. | |
| echo %DownloadDirectory% | |
| echo. | |
| echo. | |
| :OutputSaveDir | |
| if "%SaveDirectory%"=="" goto EndBatch | |
| if "%SaveDirectory:~-1%"=="\" set "SaveDirectory=%SaveDirectory:~0,-1%" | |
| echo Save directory of Internet Explorer is: | |
| echo. | |
| echo %SaveDirectory% | |
| :EndBatch | |
| endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment