VBS 腳本由 wscript.exe (GUI) 或 cscript.exe (CLI) 解釋執行,是 Windows 自動化管理利器。四大安全實戰腳本:
Dim WSH
Set WSH = WScript.CreateObject("WScript.Shell")
WSH.Popup "解鎖登錄表編輯器!"
WSH.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools", 0, "REG_DWORD"
WSH.Popup "登錄表解鎖成功!"
存為 .vbs 雙擊執行,即時解除限制。
Dim WSHShell, fso, dc
Set WSHShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d In dc
WSHShell.Run "net share " & d.DriveLetter & "$ /delete"
Next
WSHShell.Run "net share admin$ /delete"
WSHShell.Run "net share ipc$ /delete"
執行前後用 net share 驗證,共享列表乾淨。
Dim WS
Set WS = CreateObject("MSWinsock.Winsock")
IPAddress = WS.LocalIP
MsgBox "Local IP=" & IPAddress
存為 ShowIP.vbs 雙擊即見 IP,免輸指令。
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Backup)}!\\" & strComputer & "\root\cimv2")
Dim mylogs(3)
mylogs(1) = "application"
mylogs(2) = "system"
mylogs(3) = "security"
For Each logs In mylogs
Set colLogFiles = objWMIService.ExecQuery("Select * from Win32_NTEventLogFile where LogFileName='" & logs & "'")
For Each objLogfile In colLogFiles
objLogFile.ClearEventLog()
Next
Next
存為 cleanevent.vbs,利用 WMI ClearEventLog() 方法批次清除,繞過命令列無法停止 EventLog 服務的限制。
VBS + WSH 讓系統管理自動化、腳本化,安全運維更高效。