Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write two vbs scripts

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to write two vbs scripts". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn how to write two vbs scripts.

Set objNetwork = CreateObject ("Wscript.Network")

StrComputer = objNetwork.ComputerName

Const ForReading = 1

Const ForAppending = 8

Dim arrFileLines ()

ITunes 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

/ / check for specific characters in a specific file in the Search directory and put the results in 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

/ / clear all administrator accounts when the user logs in, keep only Administrator and NetShowServices, and change the password of Administrator to 55555555

At this point, I believe you have a deeper understanding of "how to write two vbs scripts". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report