Page 1 of 1
The system cannot find the path specified???
Posted: 21 Apr 2012 14:23
by tinfanide
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.
Re: The system cannot find the path specified???
Posted: 21 Apr 2012 16:22
by trebor68
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.
Re: The system cannot find the path specified???
Posted: 21 Apr 2012 17:23
by tinfanide
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.