Accessing the Control Panel.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
YottaByte
Posts: 19
Joined: 14 Oct 2020 13:07
Location: Argentina

Accessing the Control Panel.

#1 Post by YottaByte » 10 May 2025 05:41

Hello everyone.
I'd like to know if this script works correctly on Windows 10 PCs in English. It's about accessing the Control Panel.
Thanks!

In the following code, I've commented out the lines "start /min ConsoleNoClose.exe /ALL" and "start /min ConsoleNoClose.exe /RH" that belong to the execution of the "ConsoleNoClose" utility. This utility disables closing, maximizing, minimizing, and resizing the CMD window.
You can download the folder with the script and the "ConsoleNoClose" utility, written by Uwe Sieber, from the link at the end of this post.

Code: Select all

:: ___________________________________________
::
:: PanTrol 1.0.3
:: MarcSoft (R)
:: Copyright (C) 2025 Eduardo A. Marclay
:: ___________________________________________

:: Desactiva el eco de los comandos.
@ECHO OFF
:: Borra la ventana.
CLS
:: Establece cantidad de columnas y líneas.
	MODE CON COLS=56 LINES=32

:: Cambia las variables de entorno y habilita las extensiones
:: del procesador de comandos localmente -dentro de este batch-,
:: (cuando finaliza este bat, CMD restaura la configuración por
:: defecto).
	SETLOCAL EnableExtensions
	SETLOCAL EnableDelayedExpansion

:: Se posiciona en el directorio donde está este batch.
cd /d "%~dp0"

:: Inhabilita cerrar, maximizar, minimizar y redimensionar ventana CMD.
:: start /min ConsoleNoClose.exe /ALL

:: Establece variable "FIRMA".
SET "FIRMA=E.A.M."

:: La página de códigos actual es almacenada en la variable CodePage
:: para restaurarla al salir del Bat, luego es cambiada a 850 para el
:: correcto dibujado de la "interfaz".
FOR /F "tokens=*" %%A IN ('CHCP') DO FOR %%B IN (%%~A) DO SET "CodePage=%%B"
CHCP 850 >NUL 2>&1

:: Verifica que Pantrol se haya ejecutado como administrador,
:: en caso contrario, impedirá su ejecución y luego de mostrar
:: un mensaje de error se cerrará.
	NET FILE 1>NUL 2>NUL
	IF "%ERRORLEVEL%"=="0" (GOTO INICIO0) ELSE (GOTO NoAdmin)

:NoAdmin
	CLS
:: Reproduce un beep.
ECHO 
:: Establece cantidad de columnas y líneas.
	MODE CON COLS=55 LINES=8
:: Establece título de la ventana CMD.
	TITLE ­ERROR^^!
:: Establece color de fondo y fuente.
	COLOR 4F
ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³  PanTrol¸ DEBE SER EJECUTADO COMO ADMINISTRADOR   ³
ECHO  ³  (Click derecho, "Ejecutar como administrador")   ³
ECHO  ³            PanTrol¸ NO SE EJECUTARµ.              ³
ECHO  ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ³²²²²²²²²²²²²²²²²²² (S)Ä^> Salir ²²²²²²²²²²²²²²²²²²²²³
ECHO  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
	CHOICE /c s /n
	IF ERRORLEVEL 1 (GOTO SALE)

:INICIO0
:: -----------------------ESTABLECE VARIABLE SABOR----------------------
:: Se posiciona en el directorio donde está este batch.
:: Estos comandos son necesarios para cambiar el color 
:: de la ventana CMD de manera persistente.
cd /d "%~dp0"
:: Si existe el Archivo Col.ini, redirige a Etiqueta  :ELFOR.
	IF EXIST "%~dp0Col.ini" (GOTO ELFOR)
:: Si no existe el Archivo Col.ini establece Color a 1B.
	IF NOT EXIST "%~dp0Col.ini" SET "SABOR=1B"
ECHO %SABOR% >"%~dp0Col.ini"

:ELFOR
	FOR /F "delims=." %%A IN (Col.ini) DO CALL:TRATAR "%%A"
:: Una vez leído y procesado el archivo  se continúa con el script.
:TRATAR
:: Aquí se procesa cada línea del archivo y se guarda en la Variable SABOR.
	SET "SABOR=%~1"
:: ---------------------FIN ESTABLECMIENTO VARIABLE SABOR--------------------

:INICIO
:: Establece cantidad de columnas y líneas.
	MODE CON COLS=56 LINES=32
:: Establece color de fondo y fuente.
	COLOR %SABOR%
:: Establece título de la ventana CMD.
	TITLE PanTrol 1.0.1 - MarcSoft¸
CLS
:Interfaz
SET SABOR2=%SABOR%
	MODE CON COLS=56 LINES=32
	COLOR %SABOR%
ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³   %time:~0,2%:%time:~3,2%:%time:~6,2%    ³  P a n T r o l   ³ %DATE:~0,15% ³
ECHO  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO  ÚÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³ OPC.³          D E S C R I P C I O N E S           ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(0)ÄÅÄþ Administrador de dispositivos              ³
ECHO  ÃÄ(1)ÄÅÄþ Aplicaciones predeterminadas               ³
ECHO  ÃÄ(2)ÄÅÄþ Barra de tareas                            ³
ECHO  ÃÄ(3)ÄÅÄþ Centro de accesibilidad                    ³
ECHO  ÃÄ(4)ÄÅÄþ Centro de redes y recursos compartidos     ³
ECHO  ÃÄ(5)ÄÅÄþ Cifrado de unidad BitLocker                ³
ECHO  ÃÄ(6)ÄÅÄþ Conexiones de red                          ³
ECHO  ÃÄ(7)ÄÅÄþ Dispositivos e impresoras                  ³
ECHO  ÃÄ(8)ÄÅÄþ Fecha y hora                               ³
ECHO  ÃÄ(9)ÄÅÄþ Fuentes                                    ³
ECHO  ÃÄ(A)ÄÅÄþ Herramientas administrativas               ³
ECHO  ÃÄ(B)ÄÅÄþ Historial de archivos                      ³
ECHO  ÃÄ(C)ÄÅÄþ Idioma y regi¢n                            ³
ECHO  ÃÄ(D)ÄÅÄþ Impresoras                                 ³
ECHO  ÃÄ(E)ÄÅÄþ Mouse (Botones, Punteros, Rueda...)        ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(F)ÄÅÄþ Cambiar Color a PanTrol                    ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(P)ÄÅÄþ         Ir a p gina siguiente ÄÄ^>          ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(H)ÄÅÄþ Acerca de PanTrol                          ³
ECHO  ÃÄ(S)ÄÅÄþ Salir                                      ³
ECHO  ÀÄÄÂÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO ÚÄÄÄÙ                   P gina 1                 %FIRMA%
	CHOICE /C 0123456789ABCDEFPHSZ /N /T 60 /D Z /M ÀÄÄÄþ

	IF ERRORLEVEL 20 GOTO Interfaz
	IF ERRORLEVEL 19 GOTO Sale
	IF ERRORLEVEL 18 SET SobPan=Interfaz & (GOTO About)
	IF ERRORLEVEL 17 GOTO Siguie
	IF ERRORLEVEL 16 SET SobPan=Interfaz & (GOTO Colores)
	IF ERRORLEVEL 15 GOTO Mouse
	IF ERRORLEVEL 14 GOTO Impresor
	IF ERRORLEVEL 13 GOTO IdioRegi
	IF ERRORLEVEL 12 GOTO HistArch
	IF ERRORLEVEL 11 GOTO HerrAdm
	IF ERRORLEVEL 10 GOTO Fuentes
	IF ERRORLEVEL 9 GOTO FecHor
	IF ERRORLEVEL 8 GOTO Dispo
	IF ERRORLEVEL 7 GOTO ConexRed
	IF ERRORLEVEL 6 GOTO Bitlock
	IF ERRORLEVEL 5 GOTO Redes
	IF ERRORLEVEL 4 GOTO Acces
	IF ERRORLEVEL 3 GOTO BarTarea
	IF ERRORLEVEL 2 GOTO ApPred
	IF ERRORLEVEL 1 GOTO AdDisp

:Siguie
SET SABOR2=%SABOR%
	MODE CON COLS=56 LINES=32
	COLOR %SABOR%
ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³   %time:~0,2%:%time:~3,2%:%time:~6,2%    ³  P a n T r o l   ³ %DATE:~0,15% ³
ECHO  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO  ÚÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³ OPC.³          D E S C R I P C I O N E S           ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(0)ÄÅÄþ Opciones de energ¡a                        ³
ECHO  ÃÄ(1)ÄÅÄþ Opciones de indizaci¢n                     ³
ECHO  ÃÄ(2)ÄÅÄþ Opciones del explorador de archivos        ³
ECHO  ÃÄ(3)ÄÅÄþ Pantalla                                   ³
ECHO  ÃÄ(4)ÄÅÄþ Personalizaci¢n (fondo, colores, temas...) ³
ECHO  ÃÄ(5)ÄÅÄþ Programas y caracter¡sticas                ³
ECHO  ÃÄ(6)ÄÅÄþ Propiedades del sistema                    ³
ECHO  ÃÄ(7)ÄÅÄþ Recuperaci¢n                               ³
ECHO  ÃÄ(8)ÄÅÄþ Reproducci¢n autom tica                    ³
ECHO  ÃÄ(9)ÄÅÄþ Seguridad y mantenimiento                  ³
ECHO  ÃÄ(A)ÄÅÄþ Sistema                                    ³
ECHO  ÃÄ(B)ÄÅÄþ Sonido                                     ³
ECHO  ÃÄ(C)ÄÅÄþ Teclado                                    ³
ECHO  ÃÄ(D)ÄÅÄþ Ubicaci¢n                                  ³
ECHO  ÃÄ(E)ÄÅÄþ Windows Update                             ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(F)ÄÅÄþ Cambiar Color a PanTrol                    ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(P)ÄÅÄþ          ^<ÄÄ Ir a p gina anterior          ³
ECHO  ÃÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ÃÄ(H)ÄÅÄþ Acerca de PanTrol                          ³
ECHO  ÃÄ(S)ÄÅÄþ Salir                                      ³
ECHO  ÀÄÄÂÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO ÚÄÄÄÙ                   P gina 2                 %FIRMA%
	CHOICE /C 0123456789ABCDEFPHSZ /N /T 60 /D Z /M ÀÄÄÄþ

	IF ERRORLEVEL 20 GOTO Siguie
	IF ERRORLEVEL 19 GOTO Sale
	IF ERRORLEVEL 18 SET SobPan=Siguie & (GOTO About)
	IF ERRORLEVEL 17 GOTO Interfaz
	IF ERRORLEVEL 16 SET SobPan=Siguie & (GOTO Colores)
	IF ERRORLEVEL 15 GOTO Update
	IF ERRORLEVEL 14 GOTO Ubicac
	IF ERRORLEVEL 13 GOTO Teclado
	IF ERRORLEVEL 12 GOTO Sonido
	IF ERRORLEVEL 11 GOTO Sistema
	IF ERRORLEVEL 10 GOTO Segur
	IF ERRORLEVEL 9 GOTO RepAuto
	IF ERRORLEVEL 8 GOTO Recupera
	IF ERRORLEVEL 7 GOTO PropSist
	IF ERRORLEVEL 6 GOTO Progr
	IF ERRORLEVEL 5 GOTO Personal
	IF ERRORLEVEL 4 GOTO Panta
	IF ERRORLEVEL 3 GOTO OpExplo
	IF ERRORLEVEL 2 GOTO OpIndiz
	IF ERRORLEVEL 1 GOTO Energia

:ABOUT
	MODE CON COLS=59 LINES=9
	TITLE Acerca de Pantrol
ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³  .-._______                               _______.-.  ³
ECHO  ³-/\_)_______) þPantrol 1.0.1 (32-64 bit)þ (_______(_/\-³
ECHO  ³(   ()___)       Copyright 2025              (___()   )³
ECHO  ³    ()__)         Eduardo A. Marclay          (__()    ³
ECHO  ³-\__()_)   Contacto: e.a.marclay@gmail.com     (_()__/-³
ECHO  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO                     ³² (V)Ä^> Volver ²³
	COLOR 1B
	TIMEOUT /T 1 /NOBREAK >NUL
	COLOR 4F
	TIMEOUT /T 1 /NOBREAK >NUL
	COLOR 1B
	CHOICE /C V /N
	IF ERRORLEVEL 1 GOTO %SobPan%

:: ---------------------SELECCIÓN Y CAMBIO DE COLORES--------------------
:Colores
	COLOR %SABOR%
ECHO %SABOR% >"%~dp0Col.ini"
	FOR /F "delims=." %%A IN (Col.ini) DO CALL:TRATAR2 "%%A"
:: Una vez leído y procesado el archivo  se continúa con el script.
:TRATAR2
:: Aquí se procesa cada línea del archivo y se guarda en la Variable SABOR.
	SET "SABOR=%~1"
	MODE CON COLS=26 LINES=14
	TITLE Men£Var¸ 3.0.1 - MarcSoft¸

ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³ SELECCIONA UN COLOR  ³
ECHO  ÃÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ³Ä(A)ÄÅÄþ Azul         ³
ECHO  ³Ä(V)ÄÅÄþ Verde        ³
ECHO  ³Ä(N)ÄÅÄþ Negro        ³
ECHO  ³Ä(M)ÄÅÄþ Marino       ³
ECHO  ³Ä(O)ÄÅÄþ Ocre         ³
ECHO  ³Ä(G)ÄÅÄþ Gris         ³
ECHO  ³Ä(R)ÄÅÄþ Rojo         ³
ECHO  ÃÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO  ³²²²² (L)Ä^> Listo  ²²²²³
ECHO  ³²²² (C)Ä^> Cancelar ²²²³
ECHO  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

	CHOICE /C AVNMOGRLC /N
	IF ERRORLEVEL 9 SET SABOR=%SABOR2% & (GOTO %SobPan%)
	IF ERRORLEVEL 8 GOTO %SobPan%
	IF ERRORLEVEL 7 GOTO COLORS6
	IF ERRORLEVEL 6 GOTO COLORS5
	IF ERRORLEVEL 5 GOTO COLORS4
	IF ERRORLEVEL 4 GOTO COLORS3
	IF ERRORLEVEL 3 GOTO COLORS2
	IF ERRORLEVEL 2 GOTO COLORS1
	IF ERRORLEVEL 1 GOTO COLORS0

:: Establece colores de fondo y fuente.
:COLORS0
:: Azul
	SET "SABOR=1B" & (GOTO Colores)
:COLORS1
:: Verde
	SET "SABOR=2B" & (GOTO Colores)
:COLORS2
:: Negro
	SET "SABOR=0B" & (GOTO Colores)
:COLORS3
:: Marino
	SET "SABOR=3B" & (GOTO Colores)
:COLORS4
:: Amarillo
	SET "SABOR=6B" & (GOTO Colores)
:COLORS5
:: Gris
	SET "SABOR=8B" & (GOTO Colores)
:COLORS6
:: Rojo
	SET "SABOR=4B" & (GOTO Colores)
:: -------------------FIN SELECCIÓN Y CAMBIO DE COLORES------------------

:ConexRed
ncpa.cpl
GOTO Interfaz

:Redes
control /name Microsoft.NetworkAndSharingCenter
GOTO Interfaz

:Mouse
control /name Microsoft.Mouse
GOTO Interfaz

:Ubicac
control /name Microsoft.LocationAndOtherSensors
GOTO Siguie

:IdioRegi
control /name Microsoft.Language
GOTO Interfaz

:Teclado
control /name Microsoft.Keyboard
GOTO Siguie

:OpIndiz
control /name Microsoft.IndexingOptions
GOTO Siguie

:OpExplo
control /name Microsoft.FolderOptions
GOTO Siguie

:HistArch
control /name Microsoft.FileHistory
GOTO Interfaz

:Panta
control /name Microsoft.Display
GOTO Siguie

:ApPred
control /name Microsoft.DefaultPrograms
GOTO Interfaz

:FecHor
timedate.cpl
GOTO Interfaz

:Bitlock
control /name Microsoft.BitLockerDriveEncryption
GOTO Interfaz

:RepAuto
control /name Microsoft.AutoPlay
GOTO Siguie

:HerrAdm
control /name Microsoft.AdministrativeTools
GOTO Interfaz

:Progr
control /name Microsoft.ProgramsAndFeatures
GOTO Siguie

:AdDisp
control /name Microsoft.DeviceManager
GOTO interfaz

:Dispo
control /name Microsoft.AddHardware
GOTO Interfaz

:Segur
control /name Microsoft.ActionCenter
GOTO Siguie

:Acces
control /name Microsoft.EaseOfAccessCenter
GOTO Interfaz

:Update
control /name Microsoft.WindowsUpdate
GOTO Siguie

:BarTarea
control /name Microsoft.Taskbar
GOTO Interfaz

:PropSist
control sysdm.cpl
GOTO Siguie

:Sistema
control /name Microsoft.System
GOTO Siguie

:Sonido
control /name Microsoft.Sound
GOTO Siguie

:Recupera
control /name Microsoft.Recovery
GOTO Siguie

:Impresor
control /name Microsoft.Printers
GOTO Interfaz

:Energia
control /name Microsoft.PowerOptions
GOTO Siguie

:Personal
control /name Microsoft.Personalization
GOTO Siguie

:Fuentes
control /name Microsoft.Fonts
GOTO Interfaz

:Sale
	CD /D "%~dp0"
:: Restaura (habilita) cerrar, maximizar, minimizar y redimensionar ventana CMD.
:: start /min ConsoleNoClose.exe /RH

:: Aquí se restaura la página de códigos original.
	CHCP %CodePage% >NUL 2>&1

	CLS
	MODE CON COLS=47 LINES=4
ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³    GRACIAS POR UTILIZAR PanTrol¸ 1.0.1    ³
ECHO  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
	TIMEOUT /T 2 /NOBREAK >NUL
EXIT
https://drive.google.com/file/d/1mZXyCf ... sp=sharing

Eduardo

aGerman
Expert
Posts: 4702
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Accessing the Control Panel.

#2 Post by aGerman » 11 May 2025 03:53

Hello Eduardo,

I'm running the latest Windows 11 with German language settings. However, it seems to work and out of my experience it should work on Win 10 English as well in that case. As I don't speak Spanish, I just hope that the script really directs to the right interfaces.

Just to add...
- People who want to test the code need to save the script Windows-1252 encoded. Modern editors default to UTF-8 no BOM and even any other ANSI encodings would lead to destroyed box-drawing characters. When in doubt, better download the zip file.
- Scripts that are run as administrator still open in the console. That may change in future. Typically all text-based applications are now opened in a Windows Terminal window by default, where resizing via MODE CON doesn't work anymore.
- You're calling SETLOCAL twice (SETLOCAL EnableExtensions, SETLOCAL EnableDelayedExpansion). Everytime you're doing this, the whole environment is copied and saved in memory (for later restoration). One SETLOCAL is enough (SETLOCAL EnableExtensions EnableDelayedExpansion).
- No need for the "ConsoleNoClose" utility. Users may consider it being rude if they are not able to close the window in a usual way. As long as you don't have to do anything meaningful when the user hits the S key, don't disable the red X.

Steffen

YottaByte
Posts: 19
Joined: 14 Oct 2020 13:07
Location: Argentina

Re: Accessing the Control Panel.

#3 Post by YottaByte » 11 May 2025 06:24

Hallo Steffen.
Vielen Dank für Ihre Zeit.
I just hope that the script really directs to the right interfaces
That's precisely what I want to know.
One SETLOCAL is enough (SETLOCAL EnableExtensions EnableDelayedExpansion)
Okay, I'll change that.
Users may consider it being rude if they are not able to close the window in a usual way. As long as you don't have to do anything meaningful when the user hits the S key, don't disable the red X.
Actually, what I want is to prevent the user from resizing the CMD window because it destroys the presentation of characters in the window. Unfortunately, I haven't found a way to do this, so I resorted to ConsoleNoClose, this disables everything (close, maximize, minimize, and resize). However, you can close the window by right-clicking on the taskbar and clicking "Close Window".

Eduardo

aGerman
Expert
Posts: 4702
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Accessing the Control Panel.

#4 Post by aGerman » 11 May 2025 08:53

YottaByte wrote:
11 May 2025 06:24
I just hope that the script really directs to the right interfaces
That's precisely what I want to know.
Don't worry. If it works in Spanish, then it works in any other language as well. The parameters you pass to get to the different interfaces are not localized.
YottaByte wrote:
11 May 2025 06:24
Actually, what I want is to prevent the user from resizing the CMD window because it destroys the presentation of characters in the window.
That should be an easy task for a little PowerShell hybrid macro. I'll get back to you with a solution as soon as I find the time this evening.
However, as I already told, this will only work in a console. Windows Terminal won't allow you to do that in future.

Steffen

EDIT: Here you go ...

Code: Select all

:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@echo off

:: initialize the %noresize% macro
call :init_noresize

:: pass non-zero to disable resizing
%noresize% 1
echo resizing disabled
pause

:: pass zero to enable resizing
%noresize% 0
echo resizing enabled
pause

exit /b


:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subroutine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:: disable minimizing, maximizing, and resizing of the console window
:init_noresize
setlocal DisableDelayedExpansion
set noresize=for %%i in (1 2) do if %%i==2 (^
%=% for /f %%j in ("^^!arg^^! x") do powershell -nop -ep Bypass -c ^"try{$c=Add-Type -Name pInv -PassThru -MemberDefinition '^
%===% [DllImport(\"kernel32\")] public static extern IntPtr GetConsoleWindow();^
%===% [DllImport(\"user32\")] public static extern int GetWindowLong(IntPtr wnd,int idx);^
%===% [DllImport(\"user32\")] public static extern Int64 GetWindowLongPtr(IntPtr wnd,int idx);^
%===% [DllImport(\"user32\")] public static extern int SetWindowLong(IntPtr wnd,int idx,int newLong);^
%===% [DllImport(\"user32\")] public static extern Int64 SetWindowLongPtr(IntPtr wnd,int idx,Int64 newLong);';^
%===% $flag=0; $mask = 65536 -bOr 262144; $wnd=$c::GetConsoleWindow();^
%===% if(-not [Int32]::TryParse(\"%%~j\",[ref]$flag)){exit 1;}^
%===% if($flag -eq 0){^
%=====% if([IntPtr]::Size -eq 4){$null=$c::SetWindowLong($wnd,-16,$c::GetWindowLong($wnd,-16) -bOr $mask);}^
%=====% else{$null=$c::SetWindowLongPtr($wnd,-16,$c::GetWindowLongPtr($wnd,-16) -bOr [Int64]$mask);}}^
%===% elseif([IntPtr]::Size -eq 4){$null=$c::SetWindowLong($wnd,-16,$c::GetWindowLong($wnd,-16) -bAnd -bNot $mask);}^
%===% else{$null=$c::SetWindowLongPtr($wnd,-16,$c::GetWindowLongPtr($wnd,-16) -bAnd -bNot [Int64]$mask);}}catch{exit 1;}^"^&endlocal^
%=% ) else setlocal EnableDelayedExpansion^&set arg=
endlocal&set "noresize=%noresize%"
if !!# neq # set "noresize=%noresize:^^=%"
exit /b

:: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ magic numbers used in the code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
:: Get/SetWindowLong is used for a 32 bit process, while Get/SetWindowLongPtr is used for a 64 bit process. Distinction:
::           4      size of a memory address in a 32 bit process (it's 8 bytes for a 64 bit process), the size of IntPtr reflects this fact
::
:: window styles
::         -16      GWL_STYLE                       index used to get/set style information
::       65536      WS_MAXIMIZEBOX                  used to enable/disable the maximize button
::      262144      WS_SIZEBOX                      used to enable/disable the sizing border of the window

YottaByte
Posts: 19
Joined: 14 Oct 2020 13:07
Location: Argentina

Re: Accessing the Control Panel.

#5 Post by YottaByte » 11 May 2025 12:23

Your script works perfectly, Steffen!
But I don't know how to implement it in my script (PanTrol). Something like: "Put your script here."
I tried several ways but without success. I'll keep trying.

aGerman
Expert
Posts: 4702
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Accessing the Control Panel.

#6 Post by aGerman » 11 May 2025 12:49

The subroutine comes at the very end of your script, after your current code. Calling it to initialize the macro somewhere at the beginning, e.g. after @echo off or after setlocal. (The explanation about the meaning of the "magic numbers" is of course only a comment for those who are interested in what I did in the code. No need to include these comments.)
The rest is like
%noresize% 1
at the point where you want to disable resizing (where you have the "start /min ConsoleNoClose.exe /ALL" line), and
%noresize% 0
in case you want to enable it again (where you had "start /min ConsoleNoClose.exe /RH"). The latter is probably not neccessary because you kill the cmd session using EXIT anyway. It's also not neccessary to restore the old code page using CHCP. (Especially not if you use box drawing characters after you did that.)

Steffen

YottaByte
Posts: 19
Joined: 14 Oct 2020 13:07
Location: Argentina

Re: Accessing the Control Panel.

#7 Post by YottaByte » 11 May 2025 14:49

Done, thanks a lot, Steffen!

The link below includes both versions, Spanish and English.

https://drive.google.com/file/d/1mZXyCf ... sp=sharing

Eduardo

aGerman
Expert
Posts: 4702
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Accessing the Control Panel.

#8 Post by aGerman » 11 May 2025 16:20

I checked all menu items in the English version. All work as expected.
One minor flaw in the graphics - the date format is localized (like many other things in Batch). In my environment it's only 10 characters DD.MM.YYYY. Something like %DATE:~0,15% can't make it longer.
Fixing this is easy though.
In the :Interfaz and :Siguie parts ...

Code: Select all

SET "FECHA=%DATE%               " 
ECHO  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO  ³   %time:~0,2%:%time:~3,2%:%time:~6,2%    ³  P a n T r o l   ³ %FECHA:~0,15% ³
Steffen

YottaByte
Posts: 19
Joined: 14 Oct 2020 13:07
Location: Argentina

Re: Accessing the Control Panel.

#9 Post by YottaByte » 11 May 2025 20:50

Good morning, everyone.

Corrected and re-uploaded at the same link.
Thanks again, Steffen.

Eduardo

Post Reply