Two VBS scripts take advantage of the Wscirpt.network_vbs

Source: Internet
Author: User
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
Check 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
Clears all admin accounts when the user logs in, retains only the administrator and netshowservices, and modifies the administrator's password to 55555555

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.