From ba44b92de6d660f05f424eb998c2bee0d86dcb85 Mon Sep 17 00:00:00 2001 From: Alejandro Rosales Date: Tue, 27 May 2025 22:51:13 +0000 Subject: [PATCH] Solo la imagen --- cargar_imagen.cmd | 13 ++++++++ ejecutar_politicas.c | 73 -------------------------------------------- 2 files changed, 13 insertions(+), 73 deletions(-) create mode 100644 cargar_imagen.cmd delete mode 100644 ejecutar_politicas.c diff --git a/cargar_imagen.cmd b/cargar_imagen.cmd new file mode 100644 index 0000000..4cb1a11 --- /dev/null +++ b/cargar_imagen.cmd @@ -0,0 +1,13 @@ +@echo off +setlocal + +:: Crear el directorio si no existe +if not exist "C:\shared" ( + mkdir "C:\shared" +) + +:: Descargar la imagen +powershell -Command "Invoke-WebRequest -Uri 'https://explorer.apps.lci.ulsa.mx/files/sistemas/centro-experiencia/img0.jpg' -OutFile 'C:\shared\img0.jpg'" + +echo Imagen descargada a C:\shared\img0.jpg +pause diff --git a/ejecutar_politicas.c b/ejecutar_politicas.c deleted file mode 100644 index 9a2965c..0000000 --- a/ejecutar_politicas.c +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include - -void copiarImagen() { - const char* origen = "img0.jpg"; - const char* destinoDir = "C:\\Shared"; - const char* destino = "C:\\Shared\\img0.jpg"; - - DWORD attr = GetFileAttributesA(origen); - if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY)) { - printf("🖼️ Copiando imagen institucional a %s...\n", destino); - CreateDirectoryA(destinoDir, NULL); - if (CopyFileA(origen, destino, FALSE)) { - printf("✅ Imagen copiada correctamente.\n"); - } else { - printf("❌ Error al copiar la imagen.\n"); - } - } else { - printf("⚠️ No se encontró \"%s\". Verifica que esté en la misma carpeta que este programa.\n", origen); - } -} - -void ejecutarScripts(const char* extension) { - WIN32_FIND_DATAA findData; - HANDLE hFind; - char patron[MAX_PATH]; - snprintf(patron, MAX_PATH, "Políticas\\*.%s", extension); - - hFind = FindFirstFileA(patron, &findData); - if (hFind == INVALID_HANDLE_VALUE) return; - - do { - char comando[MAX_PATH]; - snprintf(comando, MAX_PATH, "cmd /c Políticas\\%s", findData.cFileName); - printf("----------------------------------------\n"); - printf("▶ Ejecutando: %s\n", findData.cFileName); - system(comando); - } while (FindNextFileA(hFind, &findData)); - - FindClose(hFind); -} - -int main() { - BOOL esAdmin = FALSE; - HANDLE hToken; - TOKEN_ELEVATION elevation; - DWORD size; - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) { - if (GetTokenInformation(hToken, TokenElevation, &elevation, sizeof(elevation), &size)) { - esAdmin = elevation.TokenIsElevated; - } - CloseHandle(hToken); - } - - if (!esAdmin) { - printf("🔐 Requiere privilegios de administrador. Elevando...\n"); - ShellExecuteA(NULL, "runas", GetCommandLineA(), NULL, NULL, SW_SHOWNORMAL); - return 0; - } - - printf("================================\n"); - printf("🚀 Ejecutando scripts en carpeta \"Políticas\"\n"); - printf("================================\n\n"); - - copiarImagen(); - ejecutarScripts("cmd"); - ejecutarScripts("bat"); - - printf("\n✅ Todos los scripts han sido ejecutados.\n"); - system("pause"); - return 0; -}