Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BAT file to open CMD in current directory

I have many scripts which I interact with from the command line. Everytime I need to use them, I have to open a command line window and copy+paste and CD to the path to the directory they are in. This is tedious (they are in a rather deep file system, so typing out the full path is a pain, copy+paste is better but not much). I tried to create a .BAT file that I could double-click on that would open a new command-line window in the folder the .bat file exists in but it does not work. It opens a new window, but the working directory is not the directory that .bat file is in. Here's what I've got after much googling (My cmd skills ain't so great):

cd %CD% cmd.exe 

I know from when I used Linux that Konqueror had a "Command-line window here" feature, and that's the effect I'm trying to get on Windows.

like image 552
FrustratedWithFormsDesigner Avatar asked Dec 15 '10 15:12

FrustratedWithFormsDesigner


People also ask

How do I open a command prompt in a specific folder?

Assuming that in File Explorer you have opened the target directory/folder, do this: Click on address bar, alternatively press Alt + D. Now when address bar is highlighted, type cmd in the bar. Press Enter key.


1 Answers

you probably want to do this:

cd /d %~dp0 cmd.exe 

this will set your current directory to the directory you have the batch file in

like image 148
Chris Avatar answered Sep 18 '22 05:09

Chris