TheReasonIFail Posted December 8, 2008 Share Posted December 8, 2008 (edited) OK, so I'm trying to move some information from people's "My Documents" but sadly those may sit on different locations so I'm trying to read the registry and creating a variable based on that, but it doesn't seem to be working.Here's what I'm using:FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal') DO SET PERSONAL=%%BECHO PERSONAL="%PERSONAL%"CD %PERSONAL%The echo command shows me the proper location, but when I attempt to change directory with that variable I get the following error message:The system cannot find the path specified.What am I doing wrong?!??! Edited December 8, 2008 by TheReasonIFail Link to comment Share on other sites More sharing options...
jaclaz Posted December 8, 2008 Share Posted December 8, 2008 Try this:ECHO OFFFOR /F "tokens=3 delims= " %%A IN ('REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal') DO SET PERSONAL="%%A"SET PERSONALECHO Expanding variable with CALL to SUBROUTINECALL :Expand_var %PERSONAL%ECHO Expanding variable with CALL SETCALL SET PERSONAL=%PERSONAL%SET PERSONALECHO CD %PERSONAL%pauseGOTO :EOF:Expand_varECHO CD %1GOTO :EOFjaclaz Link to comment Share on other sites More sharing options...
an3k Posted December 8, 2008 Share Posted December 8, 2008 In a batch file (.bat or .cmd) the variables need two %%, in the command line (for testing) the variables only accept one % Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now