View Single Post
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: I want to manipulate the registry key values through a vb.net application

 
0
  #2
Mar 22nd, 2005
I'm not sure what you mean by "clean" the registry key, but it's all too easy to write to the registry like this:

  1. dim WSH
  2. set WSH = createobject("WScript.Shell")
  3. WSH.RegWrite "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\url1", "http://www.google.com"

That will effectively replace the value in url1 to http://www.google.com. The most difficult Part of this will be to figure out how many url values are available. Here is a peice of code that will loop through all the registry values (urls) in that registry key, and replace them with "" (nothing).

  1. ' /* Create Shell Object */
  2. dim WSH
  3. set WSH = createobject("WScript.Shell")
  4.  
  5. ' /* Set I To 1
  6. I = 1
  7.  
  8. ' / * Loop Without Conditions (Infinately) */
  9. do
  10. ' /* If There is any kind of error, just keep processing */
  11. on error resume next
  12.  
  13. ' /* Read The String Value In The Registry Into the url Variable */
  14. url = WSH.RegRead("HKCU\Software\Microsoft\Internet Explorer\TypedURLs\url" & I)
  15.  
  16. ' /* If The Length Of What We Read From The Registry is 0, Then Break From The Loop */
  17. if len(url) = 0 then exit do
  18.  
  19. ' /* OverWrite The Current Value (current URL) with "" chr(34) is the character code for " */
  20. WSH.RegWrite "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\url" & I, chr(34) & "" & chr(34)
  21.  
  22. ' /* Reset URL */
  23. url = ""
  24.  
  25. ' /* Add One To I (To get the next URL in the registry */
  26. I = I + 1
  27. loop
  28.  
  29. ' /* All Done */
  30. msgbox "Complete!"
  31. WScript.Quit

Now, IE Still recognizes these "" values, because the values are still in the registry, but URL's have been removed. They could have been changed just as easily to say, http://www.google.com. The way to actually Remove All The Values is as such:

  1. ' /* Create Shell Object */
  2. dim WSH
  3. set WSH = createobject("WScript.Shell")
  4.  
  5. ' /* Set I To 1
  6. I = 1
  7.  
  8. ' / * Loop Without Conditions (Infinately) */
  9. do
  10. ' /* If There is any kind of error, just keep processing */
  11. on error resume next
  12.  
  13. ' /* Read The String Value In The Registry Into the url Variable */
  14. url = WSH.RegRead("HKCU\Software\Microsoft\Internet Explorer\TypedURLs\url" & I)
  15.  
  16. ' /* If The Length Of What We Read From The Registry is 0, Then Break From The Loop */
  17. if len(url) = 0 then exit do
  18.  
  19. ' /* Delete The URL From The Registry */
  20. WSH.RegDelete "HKCU\Software\Microsoft\Internet Explorer\TypedURLs\url" & I
  21.  
  22. ' /* Reset URL */
  23. url = ""
  24.  
  25. ' /* Add One To I (To get the next URL in the registry */
  26. I = I + 1
  27. loop
  28.  
  29. ' /* All Done */
  30. msgbox "Complete!"
  31. WScript.Quit

Let me know if this helps you any
Reply With Quote