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.


Chia Sẻ:
Magpress

MagPress

Vestibulum bibendum felis sit amet dolor auctor molestie. In dignissim eget nibh id dapibus. Fusce et suscipit orci. Aliquam sit amet urna lorem. Duis eu imperdiet nunc, non imperdiet libero.

0 comments so far,add yours

Cám ơn đã ghé thăm BlogCNTT!
- Mọi thắc mắc, gợi ý hoặc bình luận xin chia sẻ bên dưới hoặc Liên Hệ
- Hãy viết bằng tiếng Việt có dấu để mọi người dễ đọc hơn!
Thank You!