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
|
@echo off
|
||||||
powershell -Command "(Invoke-WebRequest -Uri 'https://api.ipify.org').Content"
|
:MENU
|
||||||
echo.
|
cls
|
||||||
echo Seleccione una opcion:
|
echo Seleccione una opcion:
|
||||||
echo 1. Obtener direccion IP externa
|
echo 1. Obtener direccion IP externa
|
||||||
echo 2. Listar archivos del directorio
|
echo 2. Listar archivos del directorio
|
||||||
echo 3. Hacer ping a Google (5 veces)
|
echo 3. Hacer ping a Google (5 veces)
|
||||||
echo.
|
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" (
|
:IP
|
||||||
echo Obteniendo IP externa...
|
powershell -Command "(Invoke-WebRequest -Uri 'https://api.ipify.org').Content"
|
||||||
powershell -Command "(Invoke-WebRequest -Uri 'https://api.ipify.org').Content"
|
pause
|
||||||
) else if "%opcion%"=="2" (
|
goto MENU
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
pause
|
:LISTAR
|
||||||
|
dir
|
||||||
|
pause
|
||||||
|
goto MENU
|
||||||
|
|
||||||
|
:PING
|
||||||
|
ping www.google.com -n 5
|
||||||
|
pause
|
||||||
|
goto MENU
|
||||||
Reference in New Issue
Block a user