Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8086

Профиль | Отправить PM | Цитировать


cinstaller, пробуйте:
Скрытый текст
Код: Выделить весь код
Option Explicit

Const ForAppending = 8
Const strPreviousIPList = "PreviousIPList.txt"

Dim strIP
Dim boolIPExists


With WScript.CreateObject("Microsoft.XMLHTTP")
	.open "GET", "http://ifconfig.me/ip", False
	.send
	
	strIP = Replace(.responseText, vbLf, "")
End With

boolIPExists = False

With WScript.CreateObject("Scripting.FileSystemObject")
	If .FileExists(strPreviousIPList) Then
		With .OpenTextFile(strPreviousIPList)
			Do Until .AtEndOfStream
				If Split(.ReadLine())(0) = strIP Then
					boolIPExists = True
					
					Exit Do
				End If
			Loop
			
			.Close
		End With
	End If
	
	If boolIPExists Then
		MsgBox "IP exists", vbOKOnly + vbExclamation, "IP exists"
	Else
		With .OpenTextFile(strPreviousIPList, ForAppending, True)
			.WriteLine strIP & " " & DateTimeNowFormat()
			
			.Close
		End With
		
		MsgBox "IP [" & strIP & "] append", vbOKOnly + vbInformation, "IP append"
	End If
End With

WScript.Quit 0

Function DateTimeNowFormat()
	Dim dtNow
	
	dtNow = Now()
	
	DateTimeNowFormat = _
		"(" & _
			DigitPad(Day(dtNow), 2) & "." & DigitPad(Month(dtNow), 2) & "." & DigitPad(Year(dtNow), 4) & _
			" / " & _
			DigitPad(Hour(dtNow), 2) & ":" & DigitPad(Minute(dtNow), 2) & _
		")"
End Function

Function DigitPad(intValue, intZeroCount)
	DigitPad = Right(String(intZeroCount, "0") & CStr(intValue), intZeroCount)
End Function
Это сообщение посчитали полезным следующие участники:

Отправлено: 03:14, 11-02-2019 | #51