Created
October 11, 2022 08:45
-
-
Save nikos3194/14513b52202df2fdbb94bf05ada458ee to your computer and use it in GitHub Desktop.
Improved batch file for CopyIP by Sordum.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo Off | |
title My Public IP Address | |
color f0 | |
:: CopyIP.exe by www.sordum.org | |
:: Download: https://www.sordum.org/9201/copy-public-ip-v1-3/ | |
:: Improved batch file by Nikos3194 (tested in Windows 7, 8.1, 10 and 11) | |
:menu | |
echo. | |
echo /====================================================\ | |
echo ( Get my public IP address using CopyIP by Sordum.org ) | |
echo \====================================================/ | |
echo. | |
echo 1 = View the current public IP adress and dump it into the log | |
echo 2 = View or edit the log | |
echo. | |
set /p q=Type a number and press enter... | |
if %q%==1 goto gen | |
if %q%==2 goto view | |
if %q%==%q% goto error | |
:view | |
if exist "%~dp0\ip_log.txt" (notepad "%~dp0\ip_log.txt") else (goto error) | |
cls | |
goto menu | |
:error | |
cls | |
echo. | |
echo The option you chose does not exist, please try again... | |
goto menu | |
:gen | |
echo. | |
echo Getting the public IP address, please wait... | |
for /f "tokens=*" %%c in ('"%~dp0\CopyIP.exe" /P') do set my_ip=%%c | |
cls | |
if "%my_ip%"=="" ( | |
echo Public IP could not be retrieved! | |
) else ( | |
echo %date% - %time:~0,8%: %my_ip%>>"%~dp0\ip_log.txt" && echo. && echo Current IP Address: %my_ip% | |
) | |
echo. | |
echo. | |
set /p x=Type 1 to return to the main menu or any other key to exit... | |
if %x%==1 goto menu | |
if %x%==%x% goto eof | |
:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment