Một số thủ thuật lập trình với ngôn ngữ Vbscript
Chúng ta copy code sau đây ở Notepad và lưu nó dưới đuôi là vbs
Chẳng hạn như vb xoá prefetch save với tên là xoa prefetch.vbs
VB Xoá prefetch để tăng tốc CPU
Dim fso
Set fso = Createobject("Scripting.FileSystemObject")
Dim MyVar
MyVar = MsgBox ("ban co muon xoa cac muc rac co trong
prefetch khong ( de tang toc CPU )?", 0, "Xoa Prefetch (tran thang
long)")
fso.DeleteFile("C:\WINDOWS\Prefetch\*.*")
VB xem ngày,giờ,tháng,năm,quý….
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from
Win32_UTCTime")
For Each objItem in colItems
Wscript.Echo "ngay: " & objItem.day
Wscript.Echo "ngay trong tuan: " & objItem.DayOfWeek
Wscript.Echo "gio: " & objItem.Hour
Wscript.Echo "phut: " & objItem.Minute
Wscript.Echo "thang: " & objItem.Month
Wscript.Echo "quy: " & objItem.Quarter
Wscript.Echo "giay: " & objItem.Second
Wscript.Echo "tuan trong thang: " & objItem.WeekInMonth
Wscript.Echo "nam: " & objItem.Year
Wscript.Echo "het roi"
Next
ElseIf n = 1 then
n = 0
WSHShell.RegWrite p, n, itemtype
WSHShell.RegWrite p1, n, itemtype
Mybox = MsgBox("Chuc nang foder option da duoc mo (chu y:
log off lai de co ket qua.)", 4096, Title911)
", 4096, Title911)
End If
VB khoá mở registry
Option Explicit
Dim WSHShell, n, MyBox, p, Titletan_co, errnum, vers, itemtype
Set WSHShell = WScript.CreateObject("WScript.Shell")
p =
"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Sy
stem\"
p = p & "DisableRegistryTools"
itemtype = "REG_DWORD"
Titletan_co = "tran thang long"
Err.Clear
On Error Resume Next
n = WSHShell.RegRead (p)
On Error Goto 0
errnum = Err.Number
if errnum <> 0 then
WSHShell.RegWrite p, 0, itemtype
End If
If n = 0 Then
n = 1
WSHShell.RegWrite p, n, itemtype
Mybox = MsgBox("registry cua ban da KHOA {~_~}' ", 4096,