View Single Post
  #2  
Old 02-25-2010, 10:18 PM
Asus's Avatar
Asus Asus is offline
Moderator
 
Join Date: May 2009
Location: San Antonio, Texas
Posts: 466
Default Part 2

You now know the basics of navigating through the registry, so now let's learn how to add values to the registry and delete them. In fact, let's learn how to do something with the registry that is actually useful. We will now make an entry in the registry that will make Notepad open when you start your computer. After testing this to make sure it worked, we will then delete it. Perhaps you are thinking that this does not sound particularly useful, but this same basic technique can be used to start just about any other program. Also, deleting the key is a method of keeping unwanted programs from starting. Ever had a program that started every time you booted your computer, and you couldn't make it stop? At the end of this tutorial you will know one way of stopping unwanted startup programs.

To make Notepad start at boot time, we have to add a REG_SZ value to the following key, giving as a data value the full path to Notepad, or better yet, notepad.exe:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run

This is one of the famous Run keys you may have heard about. We will give the value we add the name of "Notepad," but the exact name is unimportant, as long as it does not duplicate the name of a value already in the key.

Start the Registry Editor. Go to Start, click Run and then type "regedit" (without the quotes) and hit the Enter key or click OK. The Registry Editor will open. Hopefully the left pane will appear as is view 1, showing just the root keys, but regedit has the characteristic of remembering what the last key was that was selected, and is reopens to this key. If regedit was used previously on your system, it may be opened to some key deeply embedded in the tree, and what you see on the left side will be utterly confusing. You can now close the tree as shown above by going up the tree and clicking on each opened tree you encounter, but there is an easier way. Use the left arrow key in the inverted T on your keyboard. The first click of the left arrow selects the first key in the next opened key above. If you are already positioned on the first subkey of an opened key, the next click of the left arrow key will close the key. The next click will take you to the first subkey of this level of the hierarchy, and so on. This is easier to show than to explain, so just try repeatedly hitting the left arrow key, and you will find that the tree closes down to the state shown in view 1, and then down to where all you see is My Computer with a "+" next to it. At that point, one click of the right-arrow key will open My Computer to show the root keys as in view 1.

Trick 1: Learn to use the left-arrow key to collapse the tree. It is much easier than collapsing the key manually.

To go to the Run key shown above, click on the "+" next to HKEY_LOCAL_MACHINE. Next open the SOFTWARE key, this time by double-clicking SOFTWARE so as to try out the other way of opening a key. Then go on and open the next subkeys, namely Microsoft, Windows, and CurrentVersion. Then go down the list of subkeys in CurrentVersion and find Run. Do not open Run, just highlight it by left-clicking once on its name. The right pane will now show you the contents of this key, certainly different from my computer, but view 3 will give you an idea of what you should see:



We will now enter a value in the Run key that will cause Notepad to start when you boot your computer.

Warning! When you make changes to the registry with regedit, the changes take place immediately! Regedit is not like most editors you have used, where the changes do not take effect until you save the file. Make a mistake, and the damage is immediate. There is also no undo in regedit. Be careful!

Left-click on the Run key in the left pane to select it. When selected it will be highlighted. In the menu at the top of regedit select Edit, and then select new. From the pop-up menu select String Value. A new value will appear in the right pane with the name of New Value #1, highlighted and ready to edit. Enter the name you want, in this case "Notepad" (without the quotes.) Hit the Enter key when you are finished entering the name. If you make a mistake and need to start, you can edit the name by highlighting the value name, selecting Edit, and then rename, or in the Edit menu you can select Delete (or hit the DEL key on your keyboard) to delete the value and start over.

Trick 2: in the explanations I just gave you above of how to create a value, or edit the name or delete the key, I instructed you to first highlight the value, and then use the Edit menu or keyboard. There is another way, which I never use because it is easier to make mistakes. You can also right-click on a key or value, which will select it and cause a menu to pop-up. You can then select Modify, Delete, etc. from this menu. If you accidentally right-click on the wrong key or value, you may not notice your mistake until it is too late, and then the damage is done. Such mistakes happen easily, as mice can be somewhat squirrelly. Using the method of first left-clicking to select, and then selecting the action from the Edit menu reduces the chances of making a mistake, as you have a better view of what you are doing. If you really do prefer right-clicking, you can get the full benefit of this trick by simply left-clicking first to select, and the right-clicking. I used this technique for four and a half years with my customers while working as a Microsoft phone support tech, and never lost a customer to regedit. This trick is the main reason why my customers computers always survived my calls.

The Notepad value we have just entered does not yet have a value assigned to it. We need to give it the path of Notepad on your system. If you are using Windows 2000 or Windows XP that was installed as an upgrade to Windows 2000, the full path name of notepad is probably a:\WINNT\notepad.exe. If you are using Windows XP the full path name is probably a:\Windows\notepad.exe. It is best to check the path of a program before entering it in a run key to be sure it is correct. Here is how I do it.

Open My Computer, the open you system drive, normally C:. Then go to the folder where the program is located, in this case WINNT or Windows, and confirm that notepad.exe is there. Then in regedit select the Notepad value by left-clicking it, and in the Edit menu (or right-click pop-up menu) select Modify, then enter the full path name of notepad.exe in the Value data editor box. Better yet, use the clipboard:

Trick3: Transfer path names using the clipboard. In My Computer go to Tools and select Folder Options. Select the View tab and in the Advanced settings box click on Display the full path in the address bar to check it. Optionally click Apply to All Folders, or Like current Folder is you wish to apply this setting to all folders. Clock Apply and OK. You now have the full path of any folder you navigate to in the Address bar, where you can copy it into the clipboard with CTRL-C, CTRL-INS, or right-click-Copy, and then past it with CTRL-V, SHIFT-INS, or right-click-Paste.

Trick 3 gets the path into the Edit String line, but you still have to add "\notepad.exe" (without the quotes) by hand. Click on OK, and then close the Registry Editor. Restart your computer, and (providing you got everything right) Notepad will start as the Desktop opens.

Now go back to Start, Run (regedit will still be there) and click OK. The registry will open to the Run key we were just using. Select the Notepad value and hit DEL on your keyboard (or use any of the other methods you now know) to delete the value. Now clean up the appearance ok regedit for the next time it is opened. Use the left-arrow key (see Trick 1) and collapse the tree down to where is looks like view 1. That way it will look good the next time someone (perhaps you) opens it.

Be careful that you do not abuse one feature of the Registry Editor. In the Edit menu there is a search function. Many users will use this search to find keys or values in the registry based on a name or data content, and based on the name or content attempt to divine their purpose, and make changes. This is a dangerous practice, that gets users in trouble! Only the programmer who programmed the code that uses these keys and values really knows what they are used for and what side effects they can have. Support technicians doing support for Microsoft are generally prohibited from having customers do registry searches except in special instances, and this is a good rule for everyone to follow.

Warning! Only make changes to the registry when you have reliable documentation for the changes you wish to make, or under the guidance of a reliable technician. Do not perform registry searches, and do not try to guess the meaning of keys and values in the registry!


__________________




R.I.P My Brother, J.M.S
USAF 1Lt, Computer/Network Tech
Air Force Security Forces
Comp Specs
CPU: Intel Core i7-965 Extreme Edition 3.9GHz
motherboard: Intel X58
www.comptechacr.com