如何编写两个vbs脚本
本篇内容主要讲解“如何编写两个vbs脚本”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“如何编写两个vbs脚本”吧!
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
到此,相信大家对“如何编写两个vbs脚本”有了更深的了解,不妨来实际操作一番吧!这里是编程网网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341