Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
shlomi1803
- Posts: 2
- Joined: 15 Sep 2010 17:04
#1
Post
by shlomi1803 » 15 Sep 2010 17:15
Hi Guys,
I'm trying to store IE download folder into a variable.
The following code works in vista but not in XP
(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
-
aGerman
- Expert
- Posts: 4693
- Joined: 22 Jan 2010 18:01
- Location: Germany
#2
Post
by aGerman » 15 Sep 2010 17:27
Use a "Tab" character as delimiter.
Regards
aGerman
-
orange_batch
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
-
Contact:
#3
Post
by orange_batch » 15 Sep 2010 19:39
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.
-
amel27
- Expert
- Posts: 177
- Joined: 04 Jun 2010 20:05
- Location: Russia
#4
Post
by amel27 » 15 Sep 2010 23:46
- 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
-
shlomi1803
- Posts: 2
- Joined: 15 Sep 2010 17:04
#5
Post
by shlomi1803 » 16 Sep 2010 05:25
orange_batch's post did the trick..
Thanks guys for your help!!