Get IP address from IPConfig, use later in code, or save [closed]

跟風遠走 提交于 2020-02-02 07:47:29

问题


Is it possible to run a code that searches IPConfig for the IP address then saves that to a text document or enters it into the prompt? I want to be able to plug my flash drive into a computer, run said batch file and either use that IP address or save it.


回答1:


FULL code

@ECHO OFF
ECHO.


FOR /F "TOKENS=2* DELIMS=:" %%A IN ('IPCONFIG ^| FIND "IPv4"') DO FOR %%B IN (%%A) DO SET IPADDR=%%B
ECHO %IPADDR% > file.txt



:End

The previous code will store your local ip into file.txt




回答2:


Just run the follow

IpConfig >> C:\myip.txt



来源:https://stackoverflow.com/questions/5414800/get-ip-address-from-ipconfig-use-later-in-code-or-save

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!