Question

I am on a work computer with dynamic IP address (Ipv4), which usually changes when I restart it. Since I sometimes need to use this PC through remote desktop connection at home I like to keep its IP address handy. But I sometimes forget to check the IP at restart, so is there a batch file or some code which can start up the cmd and display the IPv4 address everytime the computer restarts ? thanks.

Was it helpful?

Solution 2

You can set a batch file to run upon startup. The batch file should contain:

ipconfig
pause

OTHER TIPS

Simple, just create a batch file that runs ipconfig and displays the output:

start cmd /k ipconfig
exit

You'll see a console window appear on your screen each time you execute this batch file that contains the output of the ipconfig command. Among the information displayed will be the IP address for each of your computer's network adapters.

You can configure the command as appropriate, adding switches to ipconfig as desired. For example, adding the /all switch will cause additional information to be displayed.

If you wanted, you could parse the output of ipconfig, extract the IP address assigned to a particular network adapter, and display just that on the screen. That might reduce the cognitive overload. But any good Windows sysadmin can scan the output of ipconfig rather easily.

I used this in a .bat file I created some days ago and it works fine:

@echo off
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
set ip=%ip:~1%

echo %ip%

This way the IP is defined as a variable named "ip", so you can use this to do other things with your current IP.

I hope it helped somehow.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top