From 8094725d80989f73d70541d2a363f29ce8c4576a Mon Sep 17 00:00:00 2001 From: "DESKTOP-F8P3LSJ\\augusto\\dev" Date: Tue, 22 Jul 2025 15:45:09 -0400 Subject: [PATCH] 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. --- GetExternalIP.bat | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/GetExternalIP.bat b/GetExternalIP.bat index d99d543..6d6f807 100644 --- a/GetExternalIP.bat +++ b/GetExternalIP.bat @@ -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 \ No newline at end of file +:LISTAR +dir +pause +goto MENU + +:PING +ping www.google.com -n 5 +pause +goto MENU \ No newline at end of file