Friday, January 9, 2009

Enable Regedit using a VB script

Here's something that might help when a message box declaring
"Registry editing has been disable by your administrator" gets thrown at your face.

This script is by Doug Knox and has helped me a lot specially when some stupid virus wouldn't allow me to access the registry.

Here's the link:
http://www.dougknox.com/security/scripts/regtools.vbs

alternate link:
http://www.mediafire.com/?lbiymmznktw

Here's the code which you can paste in notepad and then save with a '.vbs' extension.

'Enable/Disable Registry Editing tools
'© Doug Knox - rev 12/06/99

Option Explicit

'Declare variables
Dim WSHShell, n, MyBox, p, t, mustboot, errnum, vers
Dim enab, disab, jobfunc, itemtype

Set WSHShell = WScript.CreateObject("WScript.Shell")
p = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\"
p = p & "DisableRegistryTools"
itemtype = "REG_DWORD"
mustboot = "Log off and back on, or restart your pc to" & vbCR & "effect the changes"
enab = "ENABLED"
disab = "DISABLED"
jobfunc = "Registry Editing Tools are now "

'This section tries to read the registry key value. If not present an
'error is generated. Normal error return should be 0 if value is
'present
t = "Confirmation"
Err.Clear
On Error Resume Next
n = WSHShell.RegRead (p)
On Error Goto 0
errnum = Err.Number

if errnum <> 0 then
'Create the registry key value for DisableRegistryTools with value 0
WSHShell.RegWrite p, 0, itemtype
End If

'If the key is present, or was created, it is toggled
'Confirmations can be disabled by commenting out
'the two MyBox lines below

If n = 0 Then
n = 1
WSHShell.RegWrite p, n, itemtype
Mybox = MsgBox(jobfunc & disab & vbCR & mustboot, 4096, t)
ElseIf n = 1 then
n = 0
WSHShell.RegWrite p, n, itemtype
Mybox = MsgBox(jobfunc & enab & vbCR & mustboot, 4096, t)
End If

Check out Doug's website (http://www.dougknox.com/) for interesting scripts.

1 comment:

  1. Looking to find what Doug's script does to the registry, ie; my regedit v5 simply fails to find when search is attempted, keys seems to be all there, but the search fails to find any key I type in (and no I haven't ticked the search box's 'match exact text'). I'd like to try Doug's fix, but too little is disclosed about it, ie; how to un-do it if things go south, not to mention how to use it once it's run.

    ReplyDelete