DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Finished Programs => Topic started by: Deozaan on June 16, 2010, 01:39 PM

Title: SOLVED: Open command prompt at current directory
Post by: Deozaan on June 16, 2010, 01:39 PM
I've been playing around with Mercurial and the GUI provided by TortoiseHg and I've decided I don't like TortoiseHg that much. But I also don't like leaving the command prompt open all the time just for an occasional repository action. And I also don't like Win+R -> cmd -> [series of commands that navigate to the repo directory].

What I'd really like is some easy way to open a directory I'm in (from Windows Explorer) in the command prompt. Whether it's a shell extension so right click -> "Open dir in cmd" or if it's in the SendTo -> Cmd or even I guess a hotkey (though I'd rather not run a little hotkey app the whole time just for this one little use case scenario).

I thought I saw something like this already on DC but I can't find it. So if it already exists, please help point me to it. If not, please someone take up the cause and code it! :)

EDIT: Krishean made it super easy! (click the blue text below to quickly get to the download)

I took the liberty of compiling everything listed in the thread into one reg file (and one to reverse the changes)

features:
works on windows 7 (should work the same on both x86 and x64) dunno if it does anything on xp, may or may not work on vista
works with rightclicking on a blank area of the directory
works with rightclicking on a drive or directory
shift+rightclicking adds the additional option of "Open administrator command window here"
Title: Re: IDEA: Open command prompt at current directory
Post by: AndyM on June 16, 2010, 02:22 PM
Google

Open Command Prompt Here
Title: Re: IDEA: Open command prompt at current directory
Post by: rjbull on June 16, 2010, 02:51 PM
It's one of the features built into Listary (http://www.listary.com/), even the free-for-personal-use version.  But, it's another app to run and another hotkey, though you might like Listary's other features enough to run it anyway.  However, I suspect you're thinking of DOSHERE, mentioned in e.g. Feature Request - right click on results Command prompt here option (https://www.donationcoder.com/forum/index.php?topic=14008.msg120297#msg120297).  As it's so small (just an INF file - don't ask me how to use it) I'll attach it to this post.
Title: Re: IDEA: Open command prompt at current directory
Post by: MilesAhead on June 16, 2010, 04:56 PM
http://www.favessoft.com/PromptHere.zip

It uses a hotkey rather than a context menu.  Should work on both 32 and 64 bit Windows.  At least it works for me in Vista64 and W7 32 bit.

edit: one thing different than most "command prompt here" type utilities is you can open more than one prompt.  Say you have \temp and \temp2 under C:.  Highlight them both and hit the hotkey.
You'll have a prompt for each with that folder as the current directory.

edit2: there's no unicode support. I provide source in case some may wish to investigate how to add unicode support to the program.  It's done in ahk.
Title: Re: IDEA: Open command prompt at current directory
Post by: Deozaan on June 16, 2010, 05:27 PM
Thanks for the help, everyone.

I found out from the comments in this blog (http://blog.taragana.com/index.php/archive/how-to-open-command-prompt-in-windows-7-using-shortcut/) (the blog itself wasn't very specific) that Windows 7 (and Vista) already has this built in by following these steps:

1. Select the directory so that it is highlighted
2. Hold Shift and Right Click the directory
3. Select Open Command Window Here

If you want it in XP, there's a Microsoft Windows XP PowerToy (http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx) for that. (Direct Link to EXE (http://download.microsoft.com/download/whistler/Install/2/WXP/EN-US/CmdHerePowertoySetup.exe))
Title: Re: SOLVED: Open command prompt at current directory
Post by: daddydave on June 16, 2010, 05:57 PM
In XP I used to add it to the context menu just a registry entry.
Title: Re: SOLVED: Open command prompt at current directory
Post by: AndyM on June 16, 2010, 08:34 PM
Thanks for the help, everyone.

I found out from the comments in this blog (http://blog.taragana.com/index.php/archive/how-to-open-command-prompt-in-windows-7-using-shortcut/) (the blog itself wasn't very specific) that Windows 7 (and Vista) already has this built in by following these steps:

1. Select the directory so that it is highlighted
2. Hold Shift and Right Click the directory
3. Select Open Command Window Here

I wasn't paying attention (still running XP), but one of the links I checked said something about a registry entry that would show "Open Command Window Here" even when the Shift key wasn't being held down.  If that's of any interest...
Title: Re: SOLVED: Open command prompt at current directory
Post by: Deozaan on June 17, 2010, 01:12 AM
I wasn't paying attention (still running XP), but one of the links I checked said something about a registry entry that would show "Open Command Window Here" even when the Shift key wasn't being held down.  If that's of any interest...

That does interest me.

I found this one (http://www.petri.co.il/vista_command_prompt.htm), which adds a "Run Command Prompt as Administrator Here":

[netshelter][HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Administrator Command Prompt here"
"NoWorkingDirectory"=""
 
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /k \"pushd %L && title Command Prompt\""
 
[HKEY_CLASSES_ROOT\Drive\shell\runas]
@="Administrator Command Prompt here"
"NoWorkingDirectory"=""
 
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
@="cmd.exe /k \"pushd %L && title Command Prompt\""

Does anyone understand this stuff well enough to modify that so it doesn't use administrator privileges? I don't need the elevated privileges.

EDIT: I think I found the answer here (http://www.howtogeek.com/howto/windows-vista/make-command-prompt-here-always-display-for-folders-in-windows-vista/), which basically says:

Rename or delete the "Extended" key for both "HKEY_CLASSES_ROOT\Drive\shell\cmd" and "HKEY_CLASSES_ROOT\Directory\shell\cmd" in the registry.

Just tested it and it works in Windows 7 (64-bit) though it should work both 32-bit and 64-bit versions (including Vista).

Thanks for pointing out this option, AndyM!
Title: Re: IDEA: Open command prompt at current directory
Post by: rjbull on June 17, 2010, 02:54 PM
Windows 7 (and Vista) already has this built in by following these steps:

1. Select the directory so that it is highlighted
2. Hold Shift and Right Click the directory
3. Select Open Command Window Here

Just tried it, and it works on Vista Home Premium in a user account with UAC On.  But if you want a DOS prompt in the current directory, you'd have to go up a level then highlight the one you've just come from, because you don't get Open Command Window Here if you right-click on a file.
Title: Re: SOLVED: Open command prompt at current directory
Post by: daddydave on June 17, 2010, 03:42 PM
Windows 7 (and Vista) already has this built in by following these steps:

1. Select the directory so that it is highlighted
2. Hold Shift and Right Click the directory
3. Select Open Command Window Here

Just tried it, and it works on Vista Home Premium in a user account with UAC On.  But if you want a DOS prompt in the current directory, you'd have to go up a level then highlight the one you've just come from, because you don't get Open Command Window Here if you right-click on a file.

You can also Shift-Right Click on a blank space within the current folder
Title: Re: SOLVED: Open command prompt at current directory
Post by: Deozaan on June 17, 2010, 03:46 PM
Windows 7 (and Vista) already has this built in by following these steps:

1. Select the directory so that it is highlighted
2. Hold Shift and Right Click the directory
3. Select Open Command Window Here

Just tried it, and it works on Vista Home Premium in a user account with UAC On.  But if you want a DOS prompt in the current directory, you'd have to go up a level then highlight the one you've just come from, because you don't get Open Command Window Here if you right-click on a file.

You can also Shift-Right Click on a blank space within the current folder

Any idea what registry setting that's under so I can remove the "Shift" requirement for it?

EDIT: Found it!

Navigate to "HKEY_CLASSES_ROOT\Directory\Background\shell\cmd" and rename or delete the "Extended" key.
Title: Re: SOLVED: Open command prompt at current directory
Post by: daddydave on June 18, 2010, 11:50 AM


Any idea what registry setting that's under so I can remove the "Shift" requirement for it?

EDIT: Found it!

Navigate to "HKEY_CLASSES_ROOT\Directory\Background\shell\cmd" and rename or delete the "Extended" key.

That gives me an idea to relegate a lot of context menu items I rarely need to that Shift key..wonder if it works in reverse.
Title: Re: SOLVED: Open command prompt at current directory
Post by: AndyM on June 18, 2010, 05:02 PM
That gives me an idea to relegate a lot of context menu items I rarely need to that Shift key..wonder if it works in reverse.
You are hereby directed to research, experiment, and report back.  ;D
Title: Re: SOLVED: Open command prompt at current directory
Post by: MilesAhead on June 18, 2010, 05:39 PM
This NirSoft utility might be useful for managing the context menu and extended context menu.  Haven't tried it yet myself though.

http://www.nirsoft.net/utils/shell_menu_view.html

Title: Re: SOLVED: Open command prompt at current directory
Post by: lanux128 on June 19, 2010, 12:25 AM
This NirSoft utility might be useful for managing the context menu and extended context menu.  Haven't tried it yet myself though.

http://www.nirsoft.net/utils/shell_menu_view.html

+1 for this tool. been using it for some time. it was helpful in snuffing out the spam WMP installs in the context-menu for the media files.
Title: Re: SOLVED: Open command prompt at current directory
Post by: rjbull on June 19, 2010, 03:30 PM
if you want a DOS prompt in the current directory, you'd have to go up a level then highlight the one you've just come from, because you don't get Open Command Window Here if you right-click on a file.

You can also Shift-Right Click on a blank space within the current folder

Yes, tried it, you're right.  Thanks!  :)
Title: Re: SOLVED: Open command prompt at current directory
Post by: Krishean on June 20, 2010, 07:56 PM
I took the liberty of compiling everything listed in the thread into one reg file (and one to reverse the changes)

features:
works on windows 7 (should work the same on both x86 and x64) dunno if it does anything on xp, may or may not work on vista
works with rightclicking on a blank area of the directory
works with rightclicking on a drive or directory
shift+rightclicking adds the additional option of "Open administrator command window here"
Title: Re: SOLVED: Open command prompt at current directory
Post by: Deozaan on June 21, 2010, 01:17 AM
I took the liberty of compiling everything listed in the thread into one reg file (and one to reverse the changes)

Awesome! Thanks! I'll update the original post to point to your download. :Thmbsup:

EDIT: Just tested both the reg and the "undo" and they work as advertised (Win7 64-bit). Thanks again!
Title: Re: SOLVED: Open command prompt at current directory
Post by: kyrathaba on July 12, 2011, 07:09 PM
Thanks for the help, everyone.

I found out from the comments in this blog (http://blog.taragana.com/index.php/archive/how-to-open-command-prompt-in-windows-7-using-shortcut/) (the blog itself wasn't very specific) that Windows 7 (and Vista) already has this built in by following these steps:

1. Select the directory so that it is highlighted
2. Hold Shift and Right Click the directory
3. Select Open Command Window Here


That is handy  :up:  Learned something new today :D
Title: Re: SOLVED: Open command prompt at current directory
Post by: MilesAhead on July 12, 2011, 07:50 PM
In XP I used to add it to the context menu just a registry entry.

PromptHere can be used on XP, Vista, and W7 both 32 and 64 bit. It doesn't use the Glass blur effect on XP.  The glass effect is optional.  Set UseGlass=0 in .ini file if you don't want it.  You can also hit the Mouse hotkey in a blank space in a folder to open the prompt in that folder.  No need to navigate up first.

Edit: I updated PromptHere so that it no longer uses a macro to get the path of the current folder. It gets the info directly from Windows:

https://www.donationcoder.com/forum/index.php?topic=22509.msg264038#msg264038

Title: Re: SOLVED: Open command prompt at current directory
Post by: Hacnstein on April 06, 2012, 07:32 AM
I like command bar explorer from
http://www.codeproject.com/Articles/2366/Command-Prompt-Explorer-Bar
I am not sure if it is for any OS past XP.  The source is there in C, any one up to updating it?  or doing a rewrite?
Title: Re: SOLVED: Open command prompt at current directory
Post by: MilesAhead on April 06, 2012, 06:36 PM
btw I did see after playing around with the Windows Seven built in context menu function that you  can select multiple folders in the same explorer window, then Shift Right Click for "open command window here."  That function will open a prompt with each folder as current directory. I've started using that on W7 just to cut down on the number of hotkey apps I'm running.  Likewise using the mouse to click on New Folder in Explorer instead of running a hotkey.