[BATCH] Evitar que se muestre la consola CMD

Iniciado por juanam2018, Enero 08, 2019, 11:54:07 PM

Tema anterior - Siguiente tema

0 Miembros y 3 Visitantes están viendo este tema.

Enero 08, 2019, 11:54:07 PM Ultima modificación: Enero 08, 2019, 11:58:34 PM por juanam2018
Hola estimados,
Este es mi 1er post, asi que me presento, mi nombre es Juan y la consulta que le estoy haciendo a la comunidad es de como ocultar la consola CMD en el siguiente código que lo uso para ejecutar .bat con privilegios de administrador:
Código: text
@if (@CodeSection == @Batch) @then
@echo off
:-------------------------------------
:: BatchGotAdmin (NO MODIFICAR privilegios de admin)
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------Debajo iría vuestro código-------------------:


Debajo de este código puede ir vuestro archivo a ejecutarse, lo que me interesa es ocultar la consola de Windows en el código que les compartí.

Ya he leído en este foro aportes que sugieren convertir el .bat a .exe, desearía mantenerlo como.bat si fuera posible.

Desde ya muchas gracias, por vuestras sugerencias.

Abrazo,
Juan

Hola @You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Revisa el siguiente post:

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Saludos

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
Hola @You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Revisa el siguiente post:

You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login

Saludos

Gracias por la ayuda, ese post ya lo había visto y no me sirve porque se abre la ventana como el mismo creador lo dice.

Además ya he probado de crear un .vbs con el siguiente contenido, pero no me oculta la ventana y aún así se ven cosas....

Código: text
set objshell = createobject("wscript.shell")
objshell.run "C:\Users\admin\miarchivo.bat",vbhide