Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
tinfanide
- Posts: 117
- Joined: 05 Sep 2011 09:15
#1
Post
by tinfanide » 21 Apr 2012 14:23
Code: Select all
@ECHO ON
CD C:\
FOR /F "tokens=3 skip=4" %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') DO CD %%A
REM should return
REM %USERPROFILE%\Desktop
REM for English-version Windows
PAUSE
I have no idea why it doesn't work with the CD command in this case.
I want to dig into the registry for the absolute path to Desktop in every Windows.
-
trebor68
- Posts: 146
- Joined: 01 Jul 2011 08:47
#2
Post
by trebor68 » 21 Apr 2012 16:22
Please change your code to:
Code: Select all
FOR /F "tokens=3 skip=4" %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') DO CALL CD /D %%A
The CALL command dissolve the "%USERPROFILE%".
With CD /D command will change also the drive letter.
-
tinfanide
- Posts: 117
- Joined: 05 Sep 2011 09:15
#3
Post
by tinfanide » 21 Apr 2012 17:23
trebor68 wrote:Please change your code to:
Code: Select all
FOR /F "tokens=3 skip=4" %%A IN ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') DO CALL CD /D %%A
The CALL command dissolve the "%USERPROFILE%".
With CD /D command will change also the drive letter.
"dissolve"?
Not until you told me did I not know the use of "call" like this.
Thank you for your help.