Right Click to Open Command Prompt in Directory

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?

Trackbacks

Trackback Address: 146/32E960656FC81573A9EB5C30A7F8153A

Comments

On 07/23/2004 at 9:49:32 AM EDT ziller wrote:
1
take a look at http://www.terabyteunlimited.com/downloads/DOSDROP.ZIP

it's free and so easy ;-)

On 07/28/2004 at 3:29:19 PM EDT finn wrote:
2
XP Powertoys adds that too.. http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

On 09/28/2004 at 6:03:24 PM EDT Sudhakar G wrote:
3
Wonderful tip.

On 01/21/2005 at 1:20:41 AM EST jacqui wrote:
4
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!

On 02/07/2005 at 4:12:31 AM EST azhou wrote:
5
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

On 10/27/2005 at 5:38:32 PM EDT Sanjeev Parasar wrote:
6
Command Prompt

On 04/22/2006 at 8:30:10 PM EDT meena wrote:
7
this is a very useful thing to have thanks for the clear explanation

On 05/17/2006 at 2:33:07 PM EDT John wrote:
8
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.

On 05/24/2006 at 4:00:59 PM EDT hi wrote:
9
i need help.. i cant open cmd on this crack of a school computer that thing they are so well protected. help me

On 06/09/2006 at 6:42:40 PM EDT NGNeer wrote:
10
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.

On 06/28/2006 at 3:22:44 PM EDT Sudhanva wrote:
11
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!!

On 06/28/2006 at 3:51:11 PM EDT Sudhanva wrote:
12
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!!!

On 07/06/2006 at 6:27:39 AM EDT Sony wrote:
13
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.

On 07/12/2006 at 12:01:52 PM EDT Dez wrote:
14
Yeah I screwed this up to, thaks for the solution too!

On 07/17/2006 at 1:22:34 PM EDT Corey wrote:
15
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.

On 11/07/2006 at 4:05:24 PM EST DeathWalker wrote:
16
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...

On 11/23/2006 at 8:40:24 PM EST potatoes wrote:
17
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"

On 12/06/2006 at 7:45:11 PM EST mikew909 wrote:
18
nice mate, that helped me out with another problem cheers!

On 12/11/2006 at 4:33:11 AM EST haresh wrote:
19
tx for the tip very helpfull save time...

On 01/11/2007 at 8:30:46 AM EST marech wrote:
20
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\""

On 02/04/2007 at 3:13:54 AM EST Raj wrote:
21
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.

On 03/16/2007 at 11:31:41 AM EDT Kyle wrote:
22
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

On 03/16/2007 at 11:32:33 AM EDT Kyle wrote:
23
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

On 03/20/2007 at 6:40:31 AM EDT Rajib wrote:
24
Sudhava,

Thanks a trillion ... wonderful solution!!!

On 03/28/2007 at 7:30:52 PM EDT ME wrote:
25
All my drives want to open in cmd.exe now! I tried the thing above but it didn't help! Can Someone HELP ME?

On 03/28/2007 at 7:59:44 PM EDT ME wrote:
26
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

On 05/05/2007 at 11:43:10 AM EDT Antonieta wrote:
27
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

On 07/24/2007 at 8:22:58 AM EDT Peter Parker wrote:
28
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/

On 10/15/2007 at 1:11:22 AM EDT cowblisdom wrote:
29
hey,birds,try this, http://www.ktechcomputing.com/cmdopen/

On 11/13/2007 at 11:25:53 PM EST suman wrote:
30
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.

On 02/16/2008 at 3:48:27 AM EST Naomi wrote:
31
Thanks heaps for this advice - took me a couple of tries, but I got it in the end.

-Naomi

On 02/21/2008 at 10:34:12 PM EST fedmich wrote:
32
How do I add an icon on the left side of the menu? Thanks in advance

On 03/03/2008 at 11:47:50 AM EST Rick wrote:
33
Because cmd.exe is on the path, you don't really need to specify anything but "cmd.exe" in the field.

On 04/23/2008 at 10:31:59 AM EDT greenie wrote:
34
Sudhanva--You da best. Thanks for the instructions on how to delete the pesky right-click Command prompt.

On 04/25/2008 at 9:01:25 PM EDT Anonymous wrote:
35
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.

On 07/02/2008 at 4:08:34 AM EDT Peter O wrote:
36
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

On 07/23/2008 at 8:58:42 AM EDT tagwar wrote:
37
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.

On 09/12/2008 at 4:00:24 AM EDT sankar wrote:
38
how do i remove Right Click to Open Command Prompt in Directory

On 09/12/2008 at 4:23:07 AM EDT sankar wrote:
39
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!!

On 09/19/2008 at 1:26:43 PM EDT Subin wrote:
40
This is great!! Right click and open Cmd window. Saves a lot of headache... copying paths, opening cmd, pasting. Thanks Pete.

On 03/09/2009 at 12:16:52 PM EDT james wrote:
41
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?

On 07/27/2009 at 11:44:53 PM EDT Sina wrote:
42
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

On 11/16/2009 at 4:14:07 AM EST rj wrote:
43
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!!

On 11/28/2009 at 4:42:28 PM EST Prasenjit wrote:
44
Excellent tip.... Very useful

On 12/03/2009 at 3:06:12 AM EST saha wrote:
45
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.

On 12/16/2009 at 12:02:00 PM EST sunil wrote:
46
when i type cmd in run command the command prompt is not opening

On 12/19/2009 at 1:53:25 AM EST jhun wrote:
47
how to delete the undeleted software use the command prompt

On 01/07/2010 at 7:18:53 AM EST Joeri wrote:
48
Anybody know how to remove the "Delete" or "Rename" form the right click menu?

On 01/15/2010 at 6:06:52 AM EST giji_DVE wrote:
49
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

On 01/20/2010 at 5:47:26 PM EST Jason Nickle wrote:
50
I love it! This is certainly the way it was intended! Thank you!

On 02/24/2010 at 3:15:39 PM EST Ari wrote:
51
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.

On 02/24/2010 at 3:16:12 PM EST Ari wrote:
52
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.

On 03/04/2010 at 12:03:36 PM EST haini wrote:
53
if i open comand prompt it z nt visible on screen what should i???????

On 05/16/2010 at 5:20:55 PM EDT Andrew wrote:
54
Thanks for this free tip. And it works! :)

On 09/06/2011 at 2:11:38 PM EDT Chathuranga wrote:
55
Hey thank. It was easier than I thought. Better to use your way instead of notepad.

On 04/03/2013 at 11:08:50 PM EDT Terry wrote:
56
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?