Input File for Script
- From: "Scott" <Scott@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 16 Dec 2005 05:44:03 -0800
I have found the below script online (Thanks Alex and Torgeir) that does
everything I need to do when searching for members of the local
administrators group. I would like to know if someone can tell me how to use
an input file to populate the aComputers field. I have a file
(computers.txt) that has all of the computers listed that I would like to
search. How can I make this script use this standard text file to input the
array of computers?
' some array with computers
aComputers = Array("computer1", "computer2")
For Each sComputer In aComputers
' check if computer is online
If IsConnectible(sComputer, 1, 750) Then
' suppress errors
On Error Resume Next
' group name to list users from
Set oGroupAdm = GetObject("WinNT://" & sComputer & "/Administrators")
If Err.Number = 0 Then
WScript.Echo "Administator members of computer: " & sComputer & vbCrLf
' loop through all member of the group
For Each oAdmGrpUser In oGroupAdm.Members
' get the name
sAdmGrpUser = oAdmGrpUser.Name
' no point in listing Administrator
' use lowercase letters in the names in the If test!
If LCase(sAdmGrpUser) <> "administrator" Then
WScript.Echo sAdmGrpUser
End If
Next
Else
WScript.Echo "Could not connect to computer: " & sComputer
End If
Else
WScript.Echo sComputer & " is not online"
End If
Err.Clear
Next
On Error Goto 0
Function IsConnectible(sHost, iPings, iTO)
' Returns True or False based on the output from ping.exe
'
' Author: Alex Angelopoulos/Torgeir Bakken
' Works an "all" WSH versions
' sHost is a hostname or IP
' iPings is number of ping attempts
' iTO is timeout in milliseconds
' if values are set to "", then defaults below used
If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = sTemp & "\runresult.tmp"
oShell.Run "%comspec% /c ping -n " & iPings & " -w " & iTO _
& " " & sHost & ">" & sTempFile, 0 , True
Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
FailIfNotExist, OpenAsDefault)
sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile(sTempFile)
Select Case InStr(sResults,"TTL=")
Case 0 IsConnectible = False
Case Else IsConnectible = True
End Select
End Function
.
- Follow-Ups:
- Re: Input File for Script
- From: Al Dunbar
- Re: Input File for Script
- Prev by Date: Re: [MSH] start the (cmd)start command
- Next by Date: [MSH] Bug in multiline expression entry?
- Previous by thread: Copy Pre-Windows 2000 data to "user logon name"
- Next by thread: Re: Input File for Script
- Index(es):
Relevant Pages
|