C.3 Turn the Address Bar into a Command Prompt

If you select Run from the Start Menu, the box that appears is essentially a limited command prompt; you can execute any program, open any folder, or launch any Internet URL simply by typing it here. Explorer and your taskbar also have the Address Bar, which accomplishes essentially the same thing as Run.

The problem with both the Run command and the Address Bar is that they can only be used to launch programs; they don't understand intrinsic DOS commands, like dir and copy (discussed earlier in this appendix). However, there is a way to have the Address Bar mimic all the functions of the Command Prompt and therefore have a true command prompt always within reach:

  1. Start by making the Address Bar visible, if it's not already. Right-click on an empty area of your taskbar; select Toolbars and then Address Bar.[B]

    [B] This solution focuses on the Address Bar on the taskbar, although it also works for the Address Bar in Explorer.

    Your taskbar will then contain the Address Bar, which is dockable, resizable, and removable: you can move it around the taskbar or even tear it off by dragging it. Your taskbar will look something like Figure C-2.

    Figure C-2. The Address Bar can be put to good use as a handy command prompt.

    figs/xpan_ac02.gif

  2. You'll immediately be able to run programs, open folders, and launch URLs simply by typing them and pressing Enter.

  3. To add DOS command functionality, you'll need the assistance of a batch file (discussed earlier in this appendix). Open a text editor, such as Notepad, and type the following:

    @echo off if "%1"=="" exit if exist c:\windows\temp\temp.bat del c:\windows\temp\temp.bat echo %1 %2 %3 %4 %5 %6 %7 %8 %9 > c:\windows\temp\temp.bat call c:\windows\temp\temp.bat if exist c:\windows\temp\temp.bat del c:\windows\temp\temp.bat

    You may have to change the references to c:\windows\temp to match the location of your Temp folder.

  4. Save it as +.bat (just the plus sign followed by the .bat filename extension) in a convenient location, such as your \Windows folder.

  5. Now, to run a DOS command from the address bar, simply precede it with a plus sign (+) and a single space, like this:

    + copy c:\bootlog.txt a:\

    You can even have the output of a DOS command redirected to a file, as follows:

    + dir c:\windows > c:\windir.txt

Here's how it works: the batch file reads what you've typed after the + and writes it to a new, but temporary, batch file. The new batch file is then executed, and the command you've typed is carried out. When it's finished, the temporary batch file is deleted.

The plus key was chosen for the name of the batch file because it's convenient and not likely to conflict with any other software or commands; the one on your keyboard's numeric keypad is usually more convenient than the one near your backspace key (Shift-=). However, you can certainly replace + with any other character, such as ` or -, as long as you rename the batch file accordingly.

There are some limitations to this design. Although it does mimic the Command Prompt, it only allows a single command at a time, after which the context is forgotten. What this means is that such commands as cd won't have much meaning you can certainly type + cd directoryname, but the "current directory" will be forgotten once the command has been executed. To get around this, include the full path with your commands. Instead of the following series of statements:

d: cd \myfolder del *.tmp

just type this:

+ del d:\myfolder\*.tmp

Of course, if you find that you need to type several consecutive commands, you can always just type cmd in the Address Bar to launch a full-fledged Command Prompt window.

C.3.1 Open a Command Prompt window in any folder

If you find yourself using the Command Prompt frequently, you'll probably benefit from the following solution. Instead of having to use the cd command to change to a given folder, you can simply open a Command Prompt window on the fly in Explorer, already rooted in the selected folder.

  1. Open the Registry Editor (discussed in Chapter 3).

  2. Expand the branches to: HKEY_CLASSES_ROOT\Directory\shell. See the discussion of file types in Chapter 4 for more information on the structure of this branch of the Registry.

  3. Create a new key by going to Edit figs/u2192.gif New figs/u2192.gif Key, and type cmd for the name of this new key.

  4. Double-click the (default) value in the new cmd key, and type the following for its contents:

    Open Command &Prompt Here
  5. Next, create a new key here by going to Edit figs/u2192.gif New figs/u2192.gif Key, and type command for the name of the new key.

  6. Double-click the (default) value in the new command key, and type the following for its contents:

    cmd.exe /k "cd %L && ver"

    This line launches the cmd.exe application, and then, using the /k parameter, instructs it to carry out the following two commands:

    cd %1 ver

    which change the working directory to the folder that has been right-clicked, and then displays the Windows version, respectively.

  7. Close the Registry Editor when you're done; the change will take effect immediately. Just right-click any folder and select Open Command Prompt Here to open a Command Prompt at the selected folder.

C.3.2 The Path Less Traveled

Although it isn't really emphasized as much as it was in the heyday of DOS and Windows 3.x, the system path is still an important setting in Windows XP. It can be helpful as well as detrimental, depending on how it's used.

The system path is simply a listing of folder names kept in memory during an entire Windows session. If a folder name is listed in your system path, you'll be able to run a program contained in that folder without having to specify its location. This is most apparent when you use the Start Menu's Run command, Explorer's Address Bar, or a Command Prompt window, and type a program filename, such as Notepad. If all is well, Notepad will start, even though you didn't specify the full path (e.g. c:\Windows) of the folder containing the notepad.exe file. This is because Notepad.exe is located in a folder that, by default, is listed in the system path.

The path is one of several environment variables that are kept in memory from Windows startup until you shut down. In previous versions of Windows, the path was set with a line in the Autoexec.bat file (now obsolete); in Windows XP, all environment variables are set by going to Control Panel figs/u2192.gif System figs/u2192.gif Advanced tabfigs/u2192.gif Environment Variables.

By default, the system variable, Path, contains the following folders:

%SystemRoot%
%SystemRoot%\system32
%SystemRoot%\system32\WBEM

This means that an executable (.exe file) placed in any of these folders is instantly accessible from any folder on the system. The %SystemRoot% element represents the Windows folder, usually c:\Windows, and is so-specified to account for systems where the Windows folder has been placed on a different drive or in a different folder.

One of the consequences of this design is that if two different versions of the same file are placed in two different folders in the path, only one of the available versions of the file and not necessarily the most recent one may be in use at any given time Now, the same rules that apply to program executables also apply to shared files, such as .dll, .vbx, and .vxd files, so the issue of version control is an important one that can affect any application on your system.

How do you escape this trap? First, remove any unnecessary directories from your path variable. Next, if you suspect a conflict with a specific file, try searching your hard disk for the filename (select Search and then For Files or Folders from the Start Menu, and select Local Hard Drives from the Look in list). If you see more than one copy of the file in the search results window, it could be causing a potential conflict. Widen the In Folder column in the search results window so you can see where each file is located. If one of them is in \Windows\System (or any other Windows subdirectories, for that matter), then it most likely belongs there. Compare the versions of the files by right-clicking, selecting Properties, and clicking on the Version tabs. Now, you want to end up with only the newest file on your system, so what you can do at this point is simply delete (or temporarily rename, to be on the safe side) all versions but the most recent. Then move the newest file to your \Windows\System32 folder if it's not already there.

Note that this solution by no means applies to all .dll files, which is why it's smart to back up any files before continuing. Some files have identical names only by coincidence, although this is rare. Of course, deleting a file just because there's another around by the same name is not a good idea unless you know that the files serve the same purpose. One way to make sure is to look through all the information in the Version tab; if the Company Name and Product Name are the same, you can be pretty sure that the files are duplicates. On the other hand, if the files have vastly different sizes, odds are that one is not a suitable replacement for the other.



Windows XP Annoyances
Fixing Windows XP Annoyances
ISBN: 0596100531
EAN: 2147483647
Year: 2005
Pages: 78
Authors: David A. Karp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net