Hi,
In a .bat file, How can I change the root path to be c:\temp\code
Hi,
In a .bat file, How can I change the root path to be c:\temp\code
Sometimes, doing cd c:\temp\code
only doesn't work if you're in another drive. This way works all the time:
c:
cd c:\temp\code
I'd suggest pushd
over cd
in this case. That way you can restore the previous directory with popd
at the end. Unless a batch file should actually change the path even after it has been run, I'd always restore it at the end of the batch:
@echo off
rem change current directory
pushd C:\Temp\Code
rem ...
rem something your batch needs to do
rem ...
rem restore old working directory
popd