分类: WINDOWS
2008-07-01 00:35:40
It’s possible to change the Windows Explorer registry settings so that you can get a command prompt
wherever you need one. For example, say you’re viewing the System32 folder and see a utility that
you’ve never seen there before. You can use this registry change to right-click the folder and choose
Command Prompt Here from the context menu to see a command prompt in that folder, rather than
your home folder, as normal. Use the following steps to make this change manually.
1.
Select the Start
Run command. Type
RegEdit in the Open field and click OK. You’ll seethe Registry Editor.
NOTE
When working with Vista, you’ll often see a User Account Control (UAC) dialog box appear thatasks whether you really intend to perform a particular action. Although this dialog box can become
quite annoying, it does serve a useful purpose in alerting you to actions from viruses and other nefarious
applications. Whenever you see the UAC dialog box and know that you’ve started a particular
action, simply click Continue and Vista will continue the action (assuming you have the proper
rights). See the “Vista Changes for the Command Line” section of the chapter for more details.
2.
Open the HKEY_CLASSES_ROOT\Folder\shell folder. Right-click this folder and chooseNew
Key from the context menu. The Registry Editor will create a new type for you.3.
Type Command_Prompt_Here as the key name and press Enter.4.
Right-click the Command_Prompt_Here key and choose New Key from the context menu.Type
command for the new key name and press Enter. You now have two new keys, as shownin Figure 1.10.
5.
Right-click the command key and choose New String Value from the context menu. Typecmd.exe /k \"cd %1\"
as the new string value. Exercise extreme care with this step. PressEnter. The new value should look like the one shown in Figure 1.10.
6.
Close the Registry Editor.Figure 1.10
Create new registry
keys to hold the Command
Prompt Here
context menu option.
Congratulations, you now have a tool that you can use to create a command prompt directly
from Windows Explorer. Open a new copy of Windows Explorer, right-click a folder, and you’ll see
the new Command Prompt Here entry. Select this option to create a new command prompt in the
folder that you right-clicked. This is the first use of the command line in this book. You can learn
more about
CMD.EXE in the “Using the CMD Switches” section of Chapter 7.You don’t have to go through this set of steps every time you want to add this feature to a copy
of Windows. The following registry script will perform the same task. To use this approach, open
a copy of Notepad and type the script shown here precisely, as shown.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here]
@="Command Prompt Here"
[HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_Here\command]
@="cmd.exe /k \"cd %1\""
When you finish, select the File
Save command. Type CommandPromptHere.REG in the FileName field. Choose All Files in the Save as Type field. Click Save. You now have a new registry
script for adding the Command Prompt Here feature. All you need to do is double-click this file in
Windows Explorer to make the addition.