I have a list of aliases defined in a command file (aliases.cmd) that I load whenver I run a command prompt (cmd.exe /k aliases.cmd). Using doskey, I have several aliases defined and I am trying to create one to show only my IP address. I came across this question with a lot of good ways to get an IP in a batch file but none of them seem to work via doskey. For example, I have this alias defined:
doskey ip=ipconfig | findstr /R /C:"IPv4 Address"
When I run it via the command prompt (excluding the doskey portion), it works and only returns the IPv4 address. However, via doskey and the "ip" keyword, it does not work and returns the regular output of "ipconfig".
Is there any way to get an IP address (and only the IP) on Windows via a doskey alias?
So after some study, the only way I could get this to work is the following.
And ip.cmd has the following.