Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the current working directory/drive in a dos batch file?

Tags:

batch-file

cd d:\projects does not work

How can I set the current working drive and directory so that I can run msbuild scripts from there?

like image 690
Maslow Avatar asked Jul 01 '10 22:07

Maslow


People also ask

How do I change the working directory in CMD?

To change current working directory under the current drive, use command " cd new-path " (change directory). It is important to take note that you need to set the current drive first (via " x: " command) before setting the current directory under the current drive.

What is the current directory in a batch file?

It is the directory from where you start the batch file. E.g. if your batch is in c:\dir1\dir2 and you do cd c:\dir3 , then run the batch, the current directory will be c:\dir3 .

How do I get the current directory in DOS?

If you want to know the current location, in which folder or directory you are while using Windows CMD (Command Line Interface), you can make use of cd command, Command: cd - This command can be used to displays the name of or to change the current directory.


1 Answers

This is also handy:

pushd D:\projects 

You can then return to the directory you were previously at with:

popd 
like image 180
Craig M Avatar answered Oct 05 '22 03:10

Craig M