shanmugharaj
shanmugharaj

Reputation: 3914

How to open a command prompt through a batch file in a specific directory?

If we open a Command Prompt it will come like

"C:\Users\......> "

Then I am doing cd "D:\Proj\sfk\net\"

To go "D:\Proj\sfk\net\"> Then from there i am executing commands say commands.

If i have batch file , On click of that it should open automatically with that path then it will be easier..

I tried

START cmd /K "D:\Proj\sfk\net\"

START cmd.exe -- "cd D:\Proj\sfk\net\"

It's not working..

How to Achieve that ?

Upvotes: 0

Views: 6208

Answers (1)

ixe013
ixe013

Reputation: 10171

Put this at the top of the batch file :

cd /d %~dp0

It will change to the directory where the batch file resides.

If you must do it without touching the batch file, then start it like this :

cmd /k "cd /d d:\temp & mybat.bat"

Upvotes: 2

Related Questions