ive written a quick .bat file that reads in the name of a directory typed in by the user, i store that variable in a variable, and then i want to actually cd to that directory.
i've tested it out with simple directories like "C:," for instance, and that works. however, when i'm dealing with the user entering in something like "C:\Documents and Settings\Desktop," i can't do cd %directory%\sampleFolder.
i keep getting an error of "the system cannot find the path specified," even though i'm using the full name. anyone know how to ov开发者_运维百科ercome this?
How about:
cd "%directory%\sampleFolder"
set /p DIR="path:"
cd %DIR%
Works just fine.
@ECHO OFF
ECHO Enter Directory
SET/p directory=
CHDIR %directory%
Works for me (Windows 7) but should work for XP/Vista/etc
精彩评论