The system cannot find the path specified???

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tinfanide
Posts: 117
Joined: 05 Sep 2011 09:15

The system cannot find the path specified???

#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

Re: The system cannot find the path specified???

#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

Re: The system cannot find the path specified???

#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.

Post Reply