Well, I thought I found the solution to my problem, but my code is not working as well as expected. Wondering if someone could shed some light on this: I'm getting Input Past End of file error when I'm trying to read the only line of text I have in a text file. By the way, I've tried While at EOF code with a loop but am still getting a "blank" variable. When I check the text file, I see the line of text in there, so it is not blank. I have a couple of tests in there (basically message boxes, and I'm outputting to test1 and test2 files...would really like to output to a file which is named by the remote computer's hostname and another file which is named by the remote computer's IP address. Here's a code snippet from a sub I created.....
Sub PS()
Const ForWriting = 2
Dim FSO
Dim FTO
Dim folderPath
Dim hostCommand
Dim IPconfigCommand
Dim hostNm
Dim objFile
Dim objReadFile
Dim objShell
Dim file1
Dim file2
Dim check
Dim check2
Dim readObject
folderPath = "C:\TOOLSQUERY"
Set FSO = CreateObject("Scripting.Fi
leSystemOb
ject")
If Not FSO.FolderExists(folderPat
h) Then
Set FTO = FSO.CreateFolder(folderPat
h)
End If
Set objShell = CreateObject("WScript.Shel
l")
Set FTO = FSO.CreateTextFile("C:\TOO
LSQUERY\" & IPVALUE & ".txt", ForWriting)
file1 = "C:\TOOLSQUERY\" & IPVALUE & ".txt"
hostCommand = "%comspec% /c psexec.exe \\" & IPValue & " " &"-accepteula hostname > C:\TOOLSQUERY\test1.txt"
check = objShell.Run(hostCommand,0
,True)
IF check = 0 Then
Set objReadFile = FSO.OpenTextFile(file1, 1)
hostNm = objReadFile.ReadLine
readObject = Split(hostNm , " ")
Msgbox readObject(0)
Else
Msgbox "Error"
Wscript.Quit
End IF
Set FTO = FSO.CreateTextFile("C:\TOO
LSQUERY\" & readObject(0) & ".txt", ForWriting)
file2 = "C:\TOOLSQUERY\" & readObject(0) & ".txt"
IPconfigCommand = "%comspec% /c psexec.exe \\" & IPValue & " " &"-accepteula ipconfig /all > C:\TOOLSQUERY.test2.txt"
check2 = objShell.Run(IPconfigComma
nd,0,True)
IF check2 = 0 Then
Call IPCounter
Else
MsgBox "Error"
Wscript.Quit
End IF
End Sub
Start Free Trial