Hi Guys, I have a script that allows me to input a range of IP's to scan and check if they're responding. If the IP responds it puts the IP into a text file. I can then use that list of IP's to do whatever I want to do on the network.
The problem is the list that is being created here has some special characters which does not allow it to be used again by any other vbscript. If you type edit c:\iplist.txt at a command prompt you can see the special characters that are causing the problem. If you open up the text file in notepad it looks fine.
Anyone have any idea on how to get around this?
Thanks, here is the code:
Fernando
The problem is the list that is being created here has some special characters which does not allow it to be used again by any other vbscript. If you type edit c:\iplist.txt at a command prompt you can see the special characters that are causing the problem. If you open up the text file in notepad it looks fine.
Anyone have any idea on how to get around this?
Thanks, here is the code:
Code:
OPTION EXPLICIT
On Error Resume Next
DIM objFSO, objOutputfile, IPlist, StartIP, StartArray
DIM strPingIP, IPOctet1, IPOctet2, IPOctet3, IPOctet4, FinalOctet, objPingIPResult, objPingIP
Const ForReading = 1
Const ForWriting = 2
IPlist = "c:\iplist.txt"
set objFSO = CreateObject("Scripting.FileSystemObject")
set objOutputfile = objFSO.CreateTextFile(IPlist,ForWriting,TRUE)
StartIP = InputBox("Enter the First IP in the range to ping. eg... 10.1.10.5")
StartArray = split(StartIP,".")
IPOctet1 = StartArray(0)
IPOctet2 = StartArray(1)
IPOctet3 = StartArray(2)
IPOctet4 = StartArray(3)
FinalOctet = InputBox("Enter just the Last Octet of the IP range to ping. eg..." & IPOctet1 & "." & IPOctet2 & "." & IPOctet3 & "." & IPOctet4 & " - " & IPOctet1 & "." & IPOctet2 & "." & IPOctet3 & "." & "XXX")
While Cint(IPOctet4) <= Cint(FinalOctet)
strPingIP = IPOctet1 & "." & IPOctet2 & "." & IPOctet3 & "." & IPOctet4
wscript.echo "Pinging... " & strPingIP
Set objPingIP = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & strPingIP & "'")
For Each objPingIPResult In objPingIP
If objPingIPResult.StatusCode = 0 Then
objOutputfile.WriteLine (strPingIP)
End if
IPOctet4 = IPOctet4 + 1
Next
Wend
Fernando