Right Click to Open Command Prompt in Directory

July 22, 2004
misc

Here's a handy tip that I got from a co-worker, who found it in the book Microsoft Visual C# .NET Step by Step. It creates a shortcut in the right click context menu of Windows Explorer to open a command prompt in the current directory. When I need to run scripts in a very long directory name, this is very handy.

So here's how you set it up:

  • Open up windows explorer
  • Tools -> Folder Options.
  • File Types Tab
  • Select the Folder file type
  • Click Advanced
  • Click New
  • For the Action type what ever you want the context menu to display, I used Command Prompt.
  • For the Application used to perform the action use c:\windows\system32\cmd.exe (note on win2k you will want to specify the winnt directory instead of the windows directory)

You can also use this feature to attach context actions to file types. Or if you want to create a right click open with option for any file type (for instance I like to be able to open any file with notepad, see: my blog entry here.



Related Entries

31 people found this page useful, what do you think?

Comments

take a look at http://www.terabyteunlimited.com/downloads/DOSDROP.ZIP it's free and so easy ;-)
XP Powertoys adds that too.. http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx
Wonderful tip.
Awesome tip on the "right click to open command prompt in directory"... very nice... i also used the tip about right clicking to notepad... extremely useful.. thanks a million!
how to add right click for creating new folder at tree list (i.e. left column of explorer, similar to acdsee 2.4 / 3.0 that you can add folder at any visible folder, saving lots of clicks and stupid layered selection); accordingly how to add an icon at explorer to create folder? I'm using win98, me, 2000 and nt
Command Prompt
this is a very useful thing to have thanks for the clear explanation
I did this and now I cant disable it or delete the entry in the advanced tab. All of my files attempt to open with cmd.exe. I cant change the default back to "open". HELP.
i need help.. i cant open cmd on this crack of a school computer that thing they are so well protected. help me
Very useful indeed. I wrote a complimentary shell extension for those cases where you're already inside the directory you want the command prompt to start in, but you don't want to have to go up one level just to right-click the folder. It's called BackgroundCMD, and it lets you start cmd.exe from the context menu of the folder background. It's also good for start cmd.exe from the desktop, without having to go to your user folder under "C:\Documents and Settings". http://www.roggel.com/NGNeer/BackgroundCMD Regards, NGNeer.
I did this and now I cant disable it or delete the entry in the advanced tab. All of my files attempt to open with cmd.exe. I cant change the default back to "open". Can anyone plz tell me how could i remove this option.. HELP!!
hi John, I myself faced the same problem like you. And then after rigorous googling I found the solution. Hope this will help u out.. With your backup in place, select Start, Run, type regedit, double-click HKEY_CLASSES_ROOT.To trim items from the right-click menu for folders, navigate the tree diagram on the left to HKEY_CLASSES_ROOT\Directory\shell. Double-click shell to see additional keys. Each key corresponds to one command on the right-click menu for folders. You won't see Windows' built-in commands for folders (you can't remove those); but you should see folders for commands that have been added by YOU or other applications. Now delete the folder that corresponds to the Command Prompt.. Now you are done!!!
Thank u so much Sudhanva.Me also had same trouble of opening all the files and folders with cmd.exe.I was searching the net for a solution and found ur post.Thank u.
Yeah I screwed this up to, thaks for the solution too!
I didnt even do anything, and this happened to my folders and drives - thanks to your info sudhavna, i figured it out. Thanx so much.
hi ppl i have a problem me problem is i need the exact line command to open folders but inside folders i mofiqued the shell on xp and now open folders in new windows this is the big problem to me imagine...
1. Open regedit 2. Navigate to HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell 3. Create a new key called Command Prompt 4. Your default value should be Command Prompt Here 5. Create a new key called Command under the Command Prompt key 6. Your default value should be cmd.exe /k pushd %L Your popup menu when you right click on a folder will now contain an option called Command Prompt Here which will open a command prompt in the selected folder. i use cmd.exe /k "cd %L" or cmd.exe /k cd %1. see here http://support.microsoft.com/kb/320148 i made this like this in windows explorer (eu fiz assim no windows explorer) folder options (opções de pastas) find the directory (ache pasta de arquivos) duble click-> advanced -> new , put the name you want (dois click-> avandado-> novo, coloca o nome que quiser) in the value put this: cmd.exe /k "cd %L" (na valor coloca isso filho: cmd.exe /k "cd %L"
nice mate, that helped me out with another problem cheers!
tx for the tip very helpfull save time...
I was looking for that and found it, very good tip. i used the regedit way: --- Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command prompt] @="Command prompt" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command prompt\command] @="cmd.exe /k \"cd %L\""
Thank u soooooooo much Sudhanva.Me also had trouble of opening all the files and folders with Print folder listing. I was searching the net for a solution and found ur post.Thank u.
Every time I try to open a folder up pops the command prompt and I can't open my folder. I have to right click and then click open in the drop down menu to open my folders. My files open fine, but my folders won't. I NEED HELP. Thanks to anyone who can give it to me. Kyle
Every time I try to open a folder up pops the command prompt and I can't open my folder. I have to right click and then click open in the drop down menu to open my folders. My files open fine, but my folders won't. I NEED HELP. Thanks to anyone who can give it to me. Kyle
Sudhava, Thanks a trillion ... wonderful solution!!!
All my drives want to open in cmd.exe now! I tried the thing above but it didn't help! Can Someone HELP ME?
I got it. I found it here: http://www.onecomputerguy.com/registry_tips.htm#doswindow Add or Edit the following Registry Keys [HKEY_CLASSES_ROOT\Directory\shell\opennew] @="Dos Prompt in that Directory" [HKEY_CLASSES_ROOT\Directory\shell\opennew\command] @="command.com /k cd %1" [HKEY_CLASSES_ROOT\Drive\shell\opennew] @="Dos Prompt in that Drive" [HKEY_CLASSES_ROOT\Drive\shell\opennew\command] @="command.com /k cd %1" These will allow you to right click on either the drive or the directory and the option of starting the dos prompt there will pop up I needed to go to drive not directory
Hi: i have a problem with open any folder, the "open" option is tha last of the tree when i right click, the default option is "search", so everytime i tried to open a folder, the search windows display. I even tried to change from the filetypes list in the toolbar, but doesn't appear the "open" option, only "find" (that is bolded). Please help me, because it's awful work like this. P.D: excuse my poor english, i don't speak it well
To fix that annoying "get search on double-click": http://www.howtogeek.com/howto/windows/how-to-fix-double-click-always-opens-search-in-windows-explorer/
hey,birds,try this, http://www.ktechcomputing.com/cmdopen/
hi everybody, To open a command prompt from the right click menu manually,as everybody said i could not find the directory [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell in my system.i could find upto [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder thats it.can any body celar my doubt.
Thanks heaps for this advice - took me a couple of tries, but I got it in the end. -Naomi
How do I add an icon on the left side of the menu? Thanks in advance
Because cmd.exe is on the path, you don't really need to specify anything but "cmd.exe" in the field.
Sudhanva--You da best. Thanks for the instructions on how to delete the pesky right-click Command prompt.
how to remove the action type I created? I had mistakenly create the prompt action to "file folder" type, now when I try to double click on a folder to open it, it instead try to do the "search" for me.
Followed your instructions exactly but it did not work for me (unless maybe I needed to reboot) but you don't say that. My OS is XP Pro with SP
to every one not able to delete the action from the list follow the below steps Click Start and select the Run option. Type "regedit" and hit enter. As with any Registry edits, you should backup your Registry before starting (File->Export->All or File->Export->Selected Branch "HKEY_CLASSES_ROOT"). Find and select the key "HKEY_CLASSES_ROOT\Directory\shell". On the right hand side of the window you will see a value named "(Default)"; double-click on this value. Set the value to "none". Once you make this change, your folders should instantly be back to normal.
how do i remove Right Click to Open Command Prompt in Directory
I did this and now I cant disable it or delete the entry in the advanced tab. All of my files attempt to open with cmd.exe. I cant change the default back to "open". Can anyone plz tell me how could i remove this option.. HELP!!
This is great!! Right click and open Cmd window. Saves a lot of headache... copying paths, opening cmd, pasting. Thanks Pete.
hey, i set my file folder default to open in search.. and i cannot set it back to open as it is not there, how do i do this?
hi i a question for get get selected directory name in vb.net or c#.net i add an item to right click folder with folder/shell and ... but i want get selected folder name in application time user do right click on the a folder and select my item thank you
I did this and now I cant disable it or delete the entry in the advanced tab. All of my files attempt to open with cmd.exe. I cant change the default back to "open". Can anyone plz tell me how could i remove this option.. HELP!!
Excellent tip.... Very useful
anyone who have problem to change back to normal please use this tip it will help you.
-goto run then type regedit
-goto hkey_classes_root->directory->shell
-modified the default data value to "none"
-then finish.
when i type cmd in run command the command prompt is not opening
how to delete the undeleted software use the command prompt
Anybody know how to remove the "Delete" or "Rename" form the right click menu?
Is there any method to retrieve the name of selected folder in Windows Explorer in C#?
I need to read the files in the selected folder, for that I have to find out the name of the selected folder.

Please Help
I love it! This is certainly the way it was intended! Thank you!
I find that being able to open the command prompt would be useful for right clicking anything. Just create a blank text document and paste the following code into it:

---Begin REG File (Don't copy this this line)---
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\OpenNew]
@="Command Prompt"
[HKEY_CLASSES_ROOT\*\Shell\OpenNew\Command]
@="cmd.exe /d cd %l"

---End REG File---

Save it as CmdEditor.reg (or whatever you would like). Run it and there you go. You can now right click ANY file to open the command prompt from its path.
I find that being able to open the command prompt would be useful for right clicking anything. Just create a blank text document and paste the following code into it:

---Begin REG File (Don't copy this this line)---

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\OpenNew]
@="Command Prompt"
[HKEY_CLASSES_ROOT\*\Shell\OpenNew\Command]
@="cmd.exe /d cd %l"

---End REG File---

Save it as CmdEditor.reg (or whatever you would like). Run it and there you go. You can now right click ANY file to open the command prompt from its path.
if i open comand prompt it z nt visible on screen what should i???????
Thanks for this free tip. And it works! :)
Hey thank. It was easier than I thought. Better to use your way instead of notepad.
How do I remove Command Promt from ... EVERY THING now that asks for it. I have no idea what I did to get it there but it is annoying and I don't know what to tell the damned thing. I messed around by accident and found if I used the 'explore' option it would allow me to see what's in a folder.

Post a Comment




  



Spell Checker by Foundeo

Recent Entries



foundeo


did you hack my cf?