Page 1 of 1

Get Internet Explorer download folder

Posted: 15 Sep 2010 17:15
by shlomi1803
Hi Guys,

I'm trying to store IE download folder into a variable.

The following code works in vista but not in XP :cry:
(vista "cuts" the spaces, XP shows the path with preceding spaces)

Can anyone please help me get it right?


@ECHO OFF

FOR /F "tokens=2* delims=REG_SZ " %%A IN (' REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer" /v "Download Directory" ') DO SET directory=%%B


echo %directory%

Thanks

Re: Get Internet Explorer download folder

Posted: 15 Sep 2010 17:27
by aGerman
Use a "Tab" character as delimiter.

Regards
aGerman

Re: Get Internet Explorer download folder

Posted: 15 Sep 2010 19:39
by orange_batch
I modify this line when querying the registry. The default delimiters are (space) and (tab), so there's no need to set it.

Code: Select all

for /f "skip=2 tokens=3*" %%x in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer" /v "Download Directory"') do set "value=%%y"


So you know, when you set delims, it makes each individual character a delimiter. It is not a string input.

Re: Get Internet Explorer download folder

Posted: 15 Sep 2010 23:46
by amel27
- on some localized Windows REG.EXE use SPACE or TAB as delimiter
- on some Windows versions REG.EXE header may be different

Code: Select all

@for /f "tokens=3* delims=    " %%x in (
'reg query "HKCU\Software\Microsoft\Internet Explorer" /v "Download Directory"^|find "REG_SZ"'
) do @set "directory=%%y"

@set directory
@pause >nul

Re: Get Internet Explorer download folder

Posted: 16 Sep 2010 05:25
by shlomi1803
orange_batch's post did the trick..

Thanks guys for your help!!