Refactor GetExternalIP.bat to include a menu for user options, allowing retrieval of external IP, directory listing, and pinging Google. Improved user interaction with prompts and error handling.
This commit is contained in:
@@ -1,26 +1,30 @@
|
||||
@echo off
|
||||
powershell -Command "(Invoke-WebRequest -Uri 'https://api.ipify.org').Content"
|
||||
echo.
|
||||
:MENU
|
||||
cls
|
||||
echo Seleccione una opcion:
|
||||
echo 1. Obtener direccion IP externa
|
||||
echo 2. Listar archivos del directorio
|
||||
echo 3. Hacer ping a Google (5 veces)
|
||||
echo.
|
||||
set /p opcion="Ingrese el numero de opcion: "
|
||||
set /p opcion=Ingrese el numero de opcion:
|
||||
if "%opcion%"=="1" goto IP
|
||||
if "%opcion%"=="2" goto LISTAR
|
||||
if "%opcion%"=="3" goto PING
|
||||
echo Opcion invalida.
|
||||
pause
|
||||
goto MENU
|
||||
|
||||
if "%opcion%"=="1" (
|
||||
echo Obteniendo IP externa...
|
||||
powershell -Command "(Invoke-WebRequest -Uri 'https://api.ipify.org').Content"
|
||||
) else if "%opcion%"=="2" (
|
||||
echo.
|
||||
echo Listando archivos del directorio:
|
||||
dir
|
||||
) else if "%opcion%"=="3" (
|
||||
echo.
|
||||
echo Haciendo ping a Google (5 veces)...
|
||||
ping -n 5 google.com
|
||||
) else (
|
||||
echo Opcion invalida
|
||||
)
|
||||
:IP
|
||||
powershell -Command "(Invoke-WebRequest -Uri 'https://api.ipify.org').Content"
|
||||
pause
|
||||
goto MENU
|
||||
|
||||
pause
|
||||
:LISTAR
|
||||
dir
|
||||
pause
|
||||
goto MENU
|
||||
|
||||
:PING
|
||||
ping www.google.com -n 5
|
||||
pause
|
||||
goto MENU
|
||||
Reference in New Issue
Block a user