Getting a Command Prompt Here in Vista

Filed under Uncategorized

Like any good developer, I have two ton crap load of Utilities, config, scripts, etc that I regularly make use of. Unfortunately, they’re all tailored towards Windows XP and I’m now in the process of setting up a Vista machine for development.

The first thing I ran into is that you can’t just dbl-click REG files anymore to merge them, unless they only modify the HKEY_CURRENT_USER hive. Grrr. Running Regedit as Admin is a workaround, albeit not a great one.

A bit more problematic, though is my favorite DOSHERE.INF file. This little jewel goes back to, what, Win95 and the old PowerToy kit, I believe.

At any rate, here’s my modified version that works fine under everything up to Vista, but no-ops now.

; "DOS Prompt Here" PowerToy
; Copyright 1996 Microsoft Corporation

CopyFiles = DosHere.Files.Inf
AddReg    = DosHere.Reg

CopyFiles = DosHere.Files.Inf
AddReg    = DosHere.Reg

DelFiles  = DosHere.Files.Inf
DelReg    = DosHere.Reg

55="DOS Prompt Here","",1


DosHere.Files.Inf = 17


;DWH Modified the below lines so that
;they work under NT
;How would you indicate the actual COMSPEC environment var?

HKLM,%UDHERE%,UninstallString,,"%10%\rundll.exe setupx.dll,InstallHinfSection DefaultUninstall 132 %17%\DosHere.inf"
;HKCR,Directory\Shell\DosHere\command,,,"%10%\ /k cd ""%1"""
HKCR,Directory\Shell\DosHere\command,,,"cmd.exe /k cd ""%1"""
;HKCR,Drive\Shell\DosHere\command,,,"%10%\ /k cd ""%1"""
HKCR,Drive\Shell\DosHere\command,,,"cmd.exe /k cd ""%1"""

DosHereName="DOS Prompt Here PowerToy"
DosHereAccel="Command &Prompt"

From what I can tell, the main problem is that INF files just can’t alter HKLM or HKCR when run as a normal user (even with admin privileges).

I have used a simple little reg script from time to time also


@="Command &Prompt Here"

@="C:\\WINDOWS\\system32\\cmd.exe /k cd \"%1\""

and this works quite nicely on 2000 and XP, but it does not work when fires via the Context Menu in the tree portion of Explorer under Vista.

However, in poking around the registry on Vista, I discovered an interesting little tidbit.

Vista already has support for a “command prompt here” built in (at least Vista Ultimate does, which is what I’m using. The reg entry looks like this:

Windows Registry Editor Version 5.00

@="Command &Prompt Here"

@="cmd.exe /s /k pushd \"%V\""

The Extended entry appears to cause the item to only show up when SHIFT is held down.

Notice the difference in the command line from the earlier version. Why the /k cd {path} doesn’t work from the tree, but the pushd %V does, who knows?

So, I hack a little to come up with this:


@="Command &Prompt Here"
;remove this property so that command shows all the time, not just when you hold down SHIFT

@="cmd.exe /s /k pushd ""%V"""

And lo, the angels sing and I can continue on my merry way.

Post a Comment

Your email is never published nor shared. Required fields are marked *