Many people that use Windows also use the Command Prompt / Command Window / DOS Prompt (or whatever you choose to call it). I use the prompt often myself (as you can see from previous posts), so it’s important to be able to navigate through folders via the prompt. I could choose to open a prompt and use cd all the time to navigate directories, or I could use a program to open a prompt already at the folder I’m in. To go even further, I could download the Microsoft PowerToy “Open Command Window Here,” or I could write it myself. I think I’ll write it myself, seeing that it takes about two lines of Registry code.
You have three choices: (1) make your own Registry script using the given code, (2) manually enter keys into the Registry the long way (a good way to learn though), and (3) download and run the script I already made for you.
(1) The .reg code view
Make your own Registry file (a .reg extension) with the following code:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmd]
@="Open Command Prompt Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\cmd\command]
@="cmd.exe /k pushd %L"
(2) Manual Registry instructions
1. Start > Run > “regedit” [Enter]
2. Open HKEY_LOCAL_MACHINE/Software/Classes/Folder/shell/
3. Right-click on Shell > New > Key
4. Name it Command Prompt (or anything you think is descriptive for yourself)
5. In the right frame, for the default value, of the Command Prompt key you just made, enter whatever text you want to appear in the context menu (e.g. Open Command Prompt Here -or- Commaaaaaannnd!)
6. Back in the left frame, right-click Command Prompt (or whatever you called it) > New > Key
7. Name this sub-key: command [Note: it must be named command to work]
8. In the right frame of command, set the default value to cmd.exe /k pushd %L
Screenshots of what your registry should look similar to (click images to enlarge):
(3) The lazy way: download and run the .reg
If you don’t want to do anything yourself, just download the registry file (.reg) and say OK to the warning. It will add the code to your registry for you.
About the Registry script
I’ve only tested this script on Windows XP Pro for my own use. Your experience may differ, so I hold no responsibility if you screw something up in your registry. This article was revisited from a previous comment of mine on Lifehacker.
The script in a nutshell:
The first line makes a registry key for the Windows Explorer shell. This name appears on the right-click context menu when you right-click a folder. The second line places the code that gets executed when you click the menu item. This line of code launches the command prompt (cmd.exe
) in interactive mode using the /k
switch. The pushd
command stores the name of the current directory, and %L places that stored name into the variable spot.
daily i gave the command in command prompt,
but now i am getting directly from here(windows)
it’s very useful for me, i am frequently using daily this command
now i am use command prompt(your hide)
Found your tip after doing a search on Google
Thanks for this tip its really useful.
Thanks for this, I had been looking for this since I had to last restore my system and undid the registry change. Especially liked your explanation of the commands (others usually don’t add that) =)
when am double clicking a folder it is opening in command mode showing full path. So i want to remove that option (i.e) i want to open a folder as explorer by double clicking. How can i remove that “command window here” option.
And also i have gone through registry setting H_root->directory->shell->cmd->command the value there is “cmd.exe /k “cd %L” ”
And in control panal->folder option->file type->selecting File folder-> set default is also not working…
so how should i resolve this problem
On win xp sp3, 32-bit, I found the pushd line not to be needed.
I also wanted to run some doskey macros before starting the shell. (Type ‘help doskey’ to learn about that in any cmd prompt).
So the command line in the registry, that works for me is a little different:
C:\windows\system32\cmd.exe /k C:\Doskey.cmd %L
I don’t use the %L command line parameter, though, don’t need it.
The contents of my C:\Doskey.cmd is:
@echo off
title “Command Line”
if EXIST C:\doskey.txt (doskey /macrofile=C:\doskey.txt) ELSE echo C:\doskey.txt is missing
prompt $S$P$G