BAT file to open CMD in current directory

Solution 1:

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

Solution 2:

Create a file named open_dos_here.cmd with the following lines:

%~d1
cd "%~p1"
call cmd

Put this file at any folder. Then, go to your Send To folder (Win+E; Alt+D;shell:sendto;Enter). Create a shortcut to point to this open_dos_here.cmd

Then, in any folder, select any file or sub-folder. Right-click and select "Send To" and then select open_dos_here.cmd to open the DOS in that folder.

Solution 3:

You can just enter cmd into the address bar in Explorer and it starts up in that path. Likewise for PowerShell.

Solution 4:

There's more simple way

start /d "folder path"

Solution 5:

As a more general solution you might want to check out the Microsoft Power Toy for XP that adds the "Open Command Window Here" option when you right-click: http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

In Vista and Windows 7, you'll get that option if you hold down shift and right-click (this is built in).