How to change directory to run .bat files from different drive?
I have some .bat files that I run from the local directory (e.g. C:\Users\pozna001). However, when I try and change the directory to a data drive using cd F:\nrcs_project
to run the .bat files from a different location, I see that the command prompt does not recognize the cd
command. How can I change the directory in the command prompt so that I can run these .bat files from a different drive (i.e. a data drive connected to a server)?
Solution 1:
CD /D F:\nrcs_project
Use the /D
switch to change current drive in addition to changing current directory for a drive.
Solution 2:
If you need to go from a device to another (in your case from C:\
to F:\
, you need to type F:
before/after you entered your cd
command, so it will go on the F
device. Otherwise, you can use the /D
parameter of the cd
function.
So to sum up,
$C:\Folder> F:
$F:\>cd F:\whatever
$F:\whatever>...
or
$C:\Folder> cd F:\whatever
$C:\Folder> F:
$F:\whatever>...
or
$C:\Folder> cd /D F:\whatever
$F:\whatever>...
Solution 3:
You first need to type F: to change to the F:\ drive, then you can use the CD command
Or you can use the /D switch to do it all in one shot:
CD /D F:\nrcs_project