MS-DOS Utility :: getip.vbs


getip.vbs displays your internet IP address. It works regardless of whether or not you are using a router. If you are connected to the internet using a router, it will display your router's IP address. If you are connected directly without a router, it will display your computer's IP address. In either case, it displays the internet IP address that the outside world sees.

Tip: You can determine your internet IP address by simply visiting or If you are using a router, these websites will show the address of your router, not the local IP address of your computer.

Tip: If your computer is directly connected to the internet (without a router), you can simply use the command: ipconfig diag show ip

Follow the steps outlined below to use the getip.vbs Visual Basic script:

  1. Click here and save as getip.txt (remember where you saved it!).

  2. Open the folder where you just saved getip.txt.

  3. To ease any security concerns you may have, double-click getip.txt to see its contents. For an explanation, see below: How getip.vbs Works.

  4. In the foler, right-click on the file and rename it to getip.vbs (.vbs files are Visual Basic files).

  5. Open an MS-MS-DOS command prompt window.

  6. Change directory to where you saved the file (use the cd command to change directory).

  7. Type: cscript getip.vbs

  8. If a firewall security warning appears that says something like "A program is attempting to connect to the internet, C:\WINDOWS\system32\cscript.exe, Microsoft (R) Console Based Script Host", click "Allow Once" (or similar firewall command). See below: How getip.vbs Works.

    Tip: For security, grant cscript.exe only one-time access (i.e.: "Allow Once" or similar firewall command); you should not allow permanent access (i.e.: "Allow" or "Allow Always" or similar firewall command).

Tip: You can hide the copyright notice that cscript outputs by using the //nologo flag (Note: two // characters). Type: cscript //nologo getip.vbs


Contents of getip.vbs:


Dim s
With CreateObject("MSXML2.XMLHTTP")
	.open "GET", "", False
	s = .ResponseText
End With

Dim x
x = InStr(s, ":")
If x > 0 Then
	s = Mid(s, x + 2)
	x = InStr(s, "<")
	If x > 0 Then
		s = Left(s, x - 1)
	End If
End If

How getip.vbs Works:

getip.vbs is a small program that works by accessing to obtain the IP address that the outside world sees. You can access that website in your web browser to see what it reports. That website simply displays a sentence such as the following:

Current IP Address:

getip.vbs takes that sentence and displays what appears after the : character.

Related Commands:

Displays internet configuration, including IP address.