Dim http, url, login, password, hostname
login = "your-login"password = "your-pass"hostname = "your-dynamic-host.ddns.ma"
' Step 1: Get current public IPSet http = CreateObject("WinHttp.WinHttpRequest.5.1")http.Open "GET", "http://checkip.dyndns.org/", Falsehttp.Send
' Parse IP from response: "Current IP Address: x.x.x.x"Dim ip, matchesSet matches = New RegExpmatches.Pattern = "(\d+\.\d+\.\d+\.\d+)"Set m = matches.Execute(http.ResponseText)ip = m(0).Value
' Step 2: Update DDNS (dyndns2 protocol)url = "https://www.ddns.ma/nic/update?hostname=" & hostname & "&myip=" & ip
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")http.Open "GET", url, Falsehttp.SetCredentials login, password, 0 ' 0 = HTTPREQUEST_SETCREDENTIALS_FOR_SERVERhttp.Send
WScript.Echo "Status: " & http.Status & " - " & http.ResponseText' Expected responses:' "good 1.2.3.4" = success, IP updated' "nochg 1.2.3.4" = no change needed' "badauth" = wrong credentials' "nohost" = hostname not found
Set http = Nothing
For ASP Classic / VBA, same logic — just replace WScript.Echo with Response.Write or Debug.Print.Key points:
/nic/update with Basic AuthSetCredentials ..., 0 sends HTTP Basic authentication&myip=, the server uses the caller's IP automatically (simpler if the request comes from the machine itself)