Set objNetwork = CreateObject("Wscript.Network") strComputer = objNetwork.ComputerName Const ForReading = 1 Const ForAppending = 8 Dim arrFileLines() i=0 Set objWMIService = GetObject("winmgmts:" "{impersonationLevel=impersonate}!\" strComputer " ootcimv2") Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Path = '\search\'") For Each objFile in colFiles If objFile.Extension = "log" Then FileName = objFile.Name Wscript.Echo FileName End IF Next Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("input.txt",ForReading) InputLine = objFile.ReadLine objFile.Close set objFile = objFSO.OpenTextFile(FileName,ForReading) Do Until objFile.AtEndOfStream SearchLine = objFile.ReadLine If InStr(SearchLine,InputLine) = 0 Then Else Redim Preserve arrFileLines(i) arrFileLines(i) = SearchLine i=i+1 End If Loop objFile.Close Set objFile = objFSO.OpenTextFile("result.txt", ForAppending) For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1 objFile.WriteLine arrFileLines(l) Next objFile.Close //檢查Search目錄中的特定文件中的特定字符并將結果放入Result.txt中。
Set objNetwork = CreateObject("Wscript.Network") strComputer = objNetwork.ComputerName StrUser = objNetwork.Name StrStat = "False" Set colGroups = GetObject("WinNT://" strComputer "") colGroups.Filter = Array("group") For Each objGroup In colGroups For Each objUser in objGroup.Members If objUser.name = StrUser Then If objGroup.Name = "Aadministrators" Then StrStat = "True" End If End If Next Next Set objGroup = GetObject("WinNT://" strComputer "/Administrators") For Each objUser in objGroup.Members If objUser.Name = "Administrator" OR objUser.Name = "NetShowServices" Then If objUser.Name = "Administrator" AND StrStat = " True " Then objUser.SetPassword "55555555" End If Else objGroup.Remove(objUser.ADsPath) End If Next //在用戶登陸的時候清除所有的管理員賬戶,只保留Administrator和NetShowServices,并修改Administrator的密碼為55555555