Quote:
Function CheckFile
Set objReadFile = WScript.Argument
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile(objReadFile, 1)
set objCreate = objFSO.CreateTextFile("results.txt", 2)
Do While Not objFile.AtEndOfStream
objStewart = objFile.ReadLine
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colPings = objWMIService.ExecQuery _
("Select * From Win32_PingStatus where Address = '" & objStewart & "'")
If Err = 0 Then
Err.Clear
For Each objPing in colPings
If objPing.StatusCode = 0 Then
objResult = objStewart & " available." & "IP Address: " & objPing.ProtocolAddress
Else
objResult = objStewart & " not available."
End If
Next
Else
Err.Clear
If ExecPing = True Then
GetName
End If
End If
objCreate.WriteLine(objResult & ": " & Now)
Loop
objFile.Close
objCreate.Close
wscript.echo "The output has been saved into the file 'results.txt'."
End Function
If I hard code the path, it works fine, but I can't get it to specify from the command prompt!