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
;
[version]
signature="$CHICAGO$"

[DosHereInstall]
CopyFiles = DosHere.Files.Inf
AddReg    = DosHere.Reg

[DefaultInstall]
CopyFiles = DosHere.Files.Inf
AddReg    = DosHere.Reg

[DefaultUnInstall]
DelFiles  = DosHere.Files.Inf
DelReg    = DosHere.Reg

[SourceDisksNames]
55="DOS Prompt Here","",1

[SourceDisksFiles]
DOSHERE.INF=55

[DestinationDirs]
DosHere.Files.Inf = 17

[DosHere.Files.Inf]
DOSHERE.INF

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

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

[Strings]
DosHereName="DOS Prompt Here PowerToy"
DosHereAccel="Command &Prompt"
UDHERE="Software\Microsoft\Windows\CurrentVersion\Uninstall\DosHere"

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

REGEDIT4

[HKEY_CLASSES_ROOT\Directory\shell\DosHere]
@="Command &Prompt Here"

[HKEY_CLASSES_ROOT\Directory\shell\DosHere\Command]
@="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

[HKEY_CLASSES_ROOT\Directory\shell\cmd]
@="Command &Prompt Here"
"Extended"=""
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\cmd\command]
@="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:

REGEDIT4

[HKEY_CLASSES_ROOT\Directory\shell\Cmd]
@="Command &Prompt Here"
;remove this property so that command shows all the time, not just when you hold down SHIFT
"Extended"=-

[HKEY_CLASSES_ROOT\Directory\shell\Cmd\Command]
@="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 *

*
*

*