thankusomuch
Goto Top

Get ip from external txt file and use in vbscript

hi everybody,

i have a little problem but iam sure its very easy stuff for u guys.

I want to recieve the ip adress from an external txt file on my server (192.168.1.101/ip.txt)


externaltxtip= ' example: "http://148.102.73.247:7476/"


i dont really want to save the file on my pc. i just want the content and past it after externaltxtip=

how can i do that


and should i write
"http://148.102.73.247:7476/"
or just
http://148.102.73.247:7476/

thanks in advance.

Content-ID: 321844

Url: https://administrator.de/forum/get-ip-from-external-txt-file-and-use-in-vbscript-321844.html

Ausgedruckt am: 20.04.2025 um 07:04 Uhr

MrCount
MrCount 23.11.2016 aktualisiert um 14:47:08 Uhr
Goto Top
Hi,

if your ip.txt is like

externaltxtip=http://148.102.73.247:7476/

and is in a shared folder, then maybe this works:
Const sInFile = "\\192.168.1.101\share\ip.txt"  
sText = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(sInFile, 1).ReadAll, "=")  
sIP = sText(1)
MsgBox sIP 
thankusomuch
thankusomuch 23.11.2016 aktualisiert um 15:19:29 Uhr
Goto Top
thanks for your help but i dont get it working.

look at this example:

Const sInFile = "http://192.168.2.101/ip.txt"
sText = Split(CreateObject("Scripting.FileSystemObject").OpenTextFile(sInFile, 1).ReadAll, "=")
sIP = sText(1)
MsgBox sIP


Dim iURL
Dim objShell
iURL =
set objShell = CreateObject("WScript.Shell")
objShell.run(iURL)


'the ip.txt is on a virtual server.


How can i make it opening the ip from the txt. iam not an expert face-sad

this is what i found:


url = "https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=nrcGOV"
'xmlHttp.setProxy 2, "www.proxy.nrc.gov:80"

Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.Open "GET", url, False
objHTTP.Send
rss = BinaryToString(objHTTP.ResponseBody)
Response.Write(rss)

Function BinaryToString(byVal Binary)
'--- Converts the binary content to text using ADODB Stream

'--- Set the return value in case of error
BinaryToString = ""

'--- Creates ADODB Stream
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")

'--- Specify stream type
BinaryStream.Type = 1 '--- adTypeBinary

'--- Open the stream And write text/string data to the object
BinaryStream.Open
BinaryStream.Write Binary

'--- Change stream type to text
BinaryStream.Position = 0
BinaryStream.Type = 2 '--- adTypeText

'--- Specify charset for the source text (unicode) data
BinaryStream.CharSet = "UTF-8"

'--- Return converted text from the object
BinaryToString = BinaryStream.ReadText
End Function


but i dont know how to use it.
131381
131381 23.11.2016 aktualisiert um 15:38:30 Uhr
Goto Top
strIP = DownloadString("http://192.168.2.101/ip.txt")  
Msgbox strIP

Function DownloadString(strURL)
    Dim objhttp
    Set objhttp = CreateObject("Microsoft.XMLHTTP")  
    With objhttp
        .Open "GET", strURL, False  
        .send
        If .Status = 200 Then
            DownloadString = .responseText
        Else
            DownloadString = ""  
        End If
    End With
End Function
Regards
thankusomuch
thankusomuch 23.11.2016 um 16:59:24 Uhr
Goto Top
thank u so much guys. looks pretty close to what i need.
but how can i make it opening in the browser instead of a message box?

many thanks
thankusomuch
thankusomuch 23.11.2016 um 20:25:16 Uhr
Goto Top
thanks
strIP = DownloadString("http://192.168.2.101/ip.txt")
Msgbox strIP
open
Function DownloadString(strURL)
Dim objhttp
Set objhttp = CreateObject("Microsoft.XMLHTTP")
With objhttp
.Open "GET", strURL, False
.send
If .Status = 200 Then
DownloadString = .responseText
Else
DownloadString = ""
End If
End With
end function

function open
Dim objShell
set objShell = CreateObject("WScript.Shell")
objShell.run(strIP)
end function