How to change the directory and run the batch file?

How do you change the directory in a batch file and then run the command in a new directory? I have a batch file to change the directory, but it will not run the command. This is not an exe, this is a file with-options. So basically I need to change the directory, and then run the command, which is saved in the line.

+5
source share
3 answers

Try using

pushd yourdir
filetorun -options
+17
source

I gave the sample code below to change the directory and run the command after that.

cd C:\    #Will change the directory to C:
ipconfig  #Will return IP address details(any command can be used here)
pause     #Will prevent command prompt from closing and waits for a keypress

Save this as the batch file filename.bat and you will get the desired result. But make sure that the command you entered is correct.

+2
source

"cd" "ChangeDirectory". "cd" .

: http://en.wikipedia.org/wiki/Cd_(command)

Greetings

+1
source

All Articles