Oct 30, 2009

Bật/ tắt Registry Editor trong Windows XP

 - Như bạn đã biết Registry là một cơ sở dữ liệu phức tạp, nó chứa các thông tin về cấu hình hệ thống và thông tin về các chương trình. Để tránh tình trạng người là sử dụng máy tính của mình để chỉnh sửa Registry, bạn có thể dùng đoạn mã sau để khóa/ mở Registry Editor (trình biên tập Registry).



Option Explicit
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 chages"
enab="ENABLED"
disab="DISABLED"
jobfunc="Registry Editing Tools are now"
t="Confirmation"
Err.Clear
On Error Resume Next
n=WSHShell.RegRead(p)
On Error Goto 0
errnum=Err.Number
If errnum0 Then
WSHShell.RegWrite p, 0, itemtype
End If
If n=0 Then
n=1
WSHShell.RegWrite p, 0, itemtype
Mybox=MsgBox(jobfunc&disab&vbCR&mustboot, 4096, t)
ElseIf n=1 Then
n=0
WSHShell.RegWrite p, 0, itemtype
Mybox=MsgBox(jobfunc&enab&vbCR&mustboot, 4096, t)
End If

 - Lưu tập tin này lại với tên DisEnableReg.vbs và chạy tập tin này. Nếu Registry đang mở thì chương trình sẽ khóa Registry lại và ngược lại.

www.taydo.info
Nguồn: Trần Hữu Phước - Echip