View Full Version : Contract Registry Tree
Paul Komski
03-16-2007, 10:44 AM
Just came across a little tweak that solves a problem (it can be a regular annoyance) for those using regedit and wanting to collapse all the open trees. Its a simple vbs script, so just copy to notepad and save as cleartree.vbs.
REM ********this will open regedit totally collapsed **************
Dim objShell, RegKey, Q
Set objShell = CreateObject("WScript.Shell")
strQuote = chr(34)
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Applets\Regedit"
RegKey = RegKey & "\LastKey"
objShell.RegWrite RegKey, ""
objShell.Run "regedit"
REM ************************************************** **
Afterthought: to save as regedit.vbs in the Windows\System32 folder. Now using the run box regedit opens with last config and regedit.vbs opens it collapsed.
;)
Sylvander
03-16-2007, 12:31 PM
Brilliant! :D :cool:
Except...
1. There were two spaces in the code I had to guess shouldn't be there and close up [is one of those wrong?]
2. I put regedit.vbs in "C:\WINDOWS\SYSTEM32", and now when I "Start->Run->Open:"...
a. regedit.vbs
Regedit always opens with all keys collapsed. :)
b. regedit
Regedit always opens with all keys collapsed. :confused: :(
Both of these after I've deliberately expanded some keys and shut regedit down in that state.
Paul Komski
03-16-2007, 08:28 PM
I hadn't spotted the blanks (eg in Curr entVersion) and I thought that specific forum bug had been ironed out when enclosed in code tags - but obviously not.
Basically the key value at:
HKCU\
Software\
Microsoft\
Windows\
CurrentVersion\
Applets\
Regedit\
LastKey
... needs to have an empty string and if so then regedit displays collapsed. Running the script should only blank that key value by setting an empty string as a one off so I dont understand why you are having problems with the tree remaining collapsed after using regedit "normally"; it remembers the tree in my situation for sure.
Functional text file attached (when its extension is changed to vbs) to avoid any forum rendering problems.
PS The code tag does work - it was my mistake to have used QUOTE tags by mistake - original thread now edited.
Fred_Flintstone
03-17-2007, 01:00 AM
Thats better... works for me now!
Thanks Paul!..:D :D
Paul Komski
03-17-2007, 05:41 AM
I had just blindly copied the code so for those who are a bit anal about their syntax it can be simplified to:
Dim objShell, RegKey
Set objShell = CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Applets\Regedit\LastKey"
objShell.RegWrite RegKey, ""
objShell.Run "regedit"
Sylvander
03-17-2007, 06:53 AM
Hmm, I replaced the regedit.vbs file with the new version [regedit.txt renamed], but still the registry is opening collapsed. :confused:
I could always resort to restoring my most recent image of C: then have a 2nd go at this.
Would like to avoid that if I can though, because I'll lose a few non-essential things.
Here's my "regedit/LastKey" data setting = "My Computer".
I notice there's a "regedit/Favourites" key with lots of keys listed as data settings there.
Paul Komski
03-17-2007, 07:24 AM
My Computer is just at the top of the regedit tree and would be rewritten when last closed. Don't know why it doesn't remember the whole tree.
The favorites is just a place to store key positions you visit regularly.
Maybe check the permissions for the relevant selected key before closing expanded. No permissions - no changes made.
Sylvander
03-17-2007, 11:39 AM
Having "Hibernated" and "Resumed" it now seems to be working OK. :confused:
What are the "permissions"?
Sylvander
03-17-2007, 12:01 PM
Notice when I open using regedit.vbs and go to the "applets/regedit" key there is no data setting at all for "LastKey". [See image below]
Little to no understanding of the "Null Value" or "Empty String" or if those are different.
Paul Komski
03-17-2007, 01:28 PM
Notice when I open using regedit.vbs and go to the "applets/regedit" key there is no data setting at all for "LastKey".That's as it should be.
Null is technically different than an empty string (or indeed a numeric value) but you cannot actually set nulls, only empty strings (strings of length=0) in string-value keys in the registry - because the type of data is not variable and is fixed before you set its value.
A few examples (VB syntax for sure):-
4 + 0 = 4
4 + null = null
"a bit of text" & "" = "a bit of text"
"a bit of text" & null = "a bit of text"
4 * "4" = 16
4 + 4 = 8
4 & 4 = 44
null * 4 = null
null * "4" = null
null * "" = null
null & "" = ""
What are the "permissions"?They are permissions (see the Edit drop down list) but if its working you have them.
vBulletin v3.6.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.