Solo la imagen
This commit is contained in:
13
cargar_imagen.cmd
Normal file
13
cargar_imagen.cmd
Normal file
@@ -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
|
||||
@@ -1,73 +0,0 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user