strComputerName = InputBox ("enter computer name")
THis script will read a text file line by line and make each line the string
until the end of the text file.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\temp\2.txt", 1)
Do Until objFile.AtEndOfStream
strComputername = objFile.ReadLine
wscript.echo strCharacters
Loop
--
Robert Cohen
A legend in his own mind
--
"Troy Mayfield" <Tmay...@trillis.com> wrote in message
news:0ace01c36c06$a7098b50$a001...@phx.gbl...
Hi
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
' input file
strInFile = "C:\logs\computer.txt"
If Not objFSO.FileExists(strInFile) Then
WScript.Echo "Could not find the input file!"
End If
Set fInFile = objFSO.OpenTextFile(strInFile, ForReading, _
FailIfNotExist, OpenAsASCII)
arrContents = Split(fInFile.ReadAll, vbCrLf)
fInFile.Close
For n = 0 to UBound(arrContents)
strComputerName = Trim(arrContents(n))
If strComputerName <> "" Then
WScript.Echo strComputerName
End If
Next
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter
I attempted to make an addition to the script with tour
responce below, but the 5 subroutines underneath the new
entry didn't seem to run as they did before (error
= "invalid procedure call or arguement: 'GetObject'".
The purpose of this script is to poll a remote computer
for its serices and report what was found to an access
database. I just wanted the script to read the hostnames
from a text file and then proceed on through the
subroutines.
Any thoughts?
>.
>
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select *
from Win32_ComputerSystem")
error = "invalid procedure call or arangement: 'get
object'"
>.
>
> here was the line it alluding to:
>
> Set CompSysSet = GetObject(strWinMgt).ExecQuery("select *
> from Win32_ComputerSystem")
>
> error = "invalid procedure call or arangement: 'get
> object'"
Hi
To little information I'm afraid (e.g. I need to see the build up of the
variable strWinMgt). Could you post your code?
Thanks,
>.
>
> Torgier,
> This script is was actually built off servinv.vbs script
> located at
> http://www.serverwatch.com/tutorials/article.php/1475601.
> Can you please show me how you can take -> strComputerName
> = InputBox ("enter computer name") and change it around so
> instead of having to manually enter the hostname, the
> hostname will be fed from a text file? Your help is
> honestly appreciated!
Hi
In the code below, consider changing
strWinMgt = "winmgmts://" & strComputerName &""
to
strWinMgt = "winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputerName & "\root\cimv2"
Here is the complete code after the Dims, before the Subs:
' Dims stop here
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
' input file
strInFile = "C:\logs\computer.txt"
If Not objFSO.FileExists(strInFile) Then
WScript.Echo "Could not find the input file!"
End If
Set fInFile = objFSO.OpenTextFile(strInFile, ForReading, _
FailIfNotExist, OpenAsASCII)
'
' Get the Computer Names to Collect Information For
'
arrContents = Split(fInFile.ReadAll, vbCrLf)
fInFile.Close
call subConnectionOpen
'
' Loop through computer names
'
For n = 0 to UBound(arrContents)
strComputerName = Trim(arrContents(n))
If strComputerName <> "" Then
strWinMgt = "winmgmts://" & strComputerName &""
'
' Write Computer Info to Database
'
call subWriteComputerInfo
call subWriteDiskInfo
call subWriteIPInfo
End If
Next
call subConnectionClose
wscript.echo "Finished Collection Information for the Systems."
' Subs starts here
Torgier,
Would you mind pasting your version of the script, with
the new editions?
>.
>
> I get the following error message -> 'the field is too
> small to accept the ammount of data you attempted to add,
> try inserting or pasting less dats' (there is only one
> hostname in the .txt file).
>
> Torgier,
> Would you mind pasting your version of the script, with
> the new editions?
That would be an error in the database writing to the mdb file I think. I did
not test that part of the code, and I have not enough knowledge of handling MS
Jet.OLEDB issues to be able to help you on this am I afraid.
>.
>
> Thats fine with me, I'll take it from here, thanks for the
> input. You are a great asset to this group!
Thanks :-)